How to prevent "Works in studio, but not in game"


  • In Studio's Play Solo mode, there is no separation of the server and client.
    This is why a LocalScript may have accessed ServerStorage, or a Script accessing LocalPlayer. The server and client are instead one. If your script "works" in studio, but not in the game, it's because of the fact there is no separation!
    Use test servers to test your scripts, as the server and client are separated. If it doesn't work there, then, ¯_(ツ)_/¯


  • I created my game and tested it and IT WORKS - all in FilteringEnabled. And yet:
    https://www.roblox.com/games/2230882108/My-WIP-RPG-Game
    "This game may not function as intended..."

    Why? I don't access ServerStorage with my LocalScripts, I don't access LocalPlayer with a Script, I use RemoteEvents. Everything works fine in a test server, but still I get the warning.


  • @Zenith_Lord people do tend to use LocalPlayer on the server though. Like, how in the world is the server going to know which player to choose? LocalPlayer is a good enough hint, yet people don't see it! And same applies to ServerStorage, ServerStorage!


  • I totally agree. But new Scripters (myself included when I was new) don't/didn't know the difference. ALTHOUGH when I was new, I never even used game.Players.LocalPlayer. I only found out when I opened up a turbofusion gun and was like "Why is there a person on this Script?" But really, no scripter should use LocalScripts until they understand the client-server connection, and how game.Players.LocalPlayer only refers to the client that is running the Script.


  • @Zenith_Lord said in How to prevent "Works in studio, but not in game":

    "Why is there a person on this Script?"

    what

    But really, no scripter should use LocalScripts until they understand the client-server connection, and how game.Players.LocalPlayer only refers to the client that is running the Script.

    Yes, but what if they wanted to make a functional GUI? They'll then be using server scripts to script GUIs, which is a bad practice. What business does the server have with GUIs? None.


  • @incapaz

    "Why is there a person on this Script?"

    what

    Meaning this:0_1534553637941_upload-af694f2a-0b57-449f-a477-a8498ad7ab8b

    Also, about your gui thing - when reading the documentation about GUIs, I read that you have to use LocalScripts with them. I kept that in mind when beginning to code with GUIs.


  • @Zenith_Lord not many people use the Wiki as a reference. They just watch some youtube tutorial and copy paste their code, or just assume that if it works in Play Solo it will in a game.


  • @incapaz I hate those types of people. I think that if you put in the effort to learn something, then do it right.


  • @Zenith_Lord I tried your game out. Pretty cool sword. Enjoy your 30 robux!


  • @DominusInfinitus Dang thanks! Pre-Alpha testers will receive a special reward when I release the game! :heart: I'll be adding the finishing touches to the sword and that will be the first weapon done! I'll message you about what the game will contain (and what extras you get).


  • @Zenith_Lord

    Bought too! Gonna play and see how is it


  • @Zenith_Lord

    Did some playtesting, and the camera kind of glitches sometimes.

    Anyway I love playing games before their release


  • Hehe I'd like to award pre-alpha testers a badge, but have 0 Robux and need 100 Robux to create a badge. Oh well... I guess a rank in the leaderstats will have to do.


  • I used to just copy and paste scripts but one day I decided to take a close look at the script I was copying and oh yes that went very well. Now when I dont know how to do something I just look it up on the wiki or ask. Also, is it bad that I'm using the workspace for number storage?


  • @mlgwinners Might be a good idea to read the blog posted by Scripting Helpers about this very topic.

    https://scriptinghelpers.org/blog/it-works-in-studio-but-not-online

Log in to reply
 

Looks like your connection to Scripting Helpers was lost, please wait while we try to reconnect.