Menu Works in Studio - Not in Game

I have a menu that allows a user to pick a track/car/num of players for the lobby, and then teleport to the corresponding place that is setup with that track, that car, and that number of players. In studio if I test the menu, the menu works great. It shows the changes the player makes, and the teleport button works correctly. I’m doing this via a system of values inside the menu. If I however turn FilteringEnabled Off, then the menu works in game, but is buggy in studio.

Any clue why this would be the case? Can a use not change values in a gui using a local script that is connected to text buttons inside that gui while FilteringEnabled is active?

Edit: For anyone looking to read over a headache inducing disaster piece to figure out why I’m doing this all wrong, or finding the more efficient way to do what I’m doing: removed file cuz pointless

1 Like

The first thing I’d try is switching the LocalScript to a ServerScript and see what happens.

If that doesn’t work, mind posting your code here?

1 Like

That’s becoming a bit of a problem. When FilteringEnabled is on, and nothing works, I get no error codes from it, so I have no clue what the problem might be. As far as switching from Local to Server, would a Server Script run inside a ScreenGUI controlled by a client? I thought you have to use Local Scripts?

And with FilteringEnabled off, everything works correctly in Studio, but in game, I get an error telling me that a certain text button is not apart of the frame that it is clearly in.
The line of code is:

local code = script.Parent.Parent.Track.TrackChoice.Value .. script.Parent.Parent.Car.CarChoice.Value .. script.Parent.Parent.Playersa.PlayerChoice.Value


1 Like

If it only works in-game with FE off, then it’s because you’re trying to access server-side instances from a local script, or trying to access client-side instances from a server script.

Would a string value inside of game.Players.(PlayerName).PlayerGui.(GuiName).Frame.TextButton be considered a server-sided object? I thought that’d be considered client sided?

Edit: A Local Script with FE On inside the Gui can switch the visibility of Frames inside a Gui, so why wouldn’t the Local Script be able to change the Value property of a String Value (Object) inside the Gui?

1 Like

Whether it’s server-side or client-side is determined on who created it. If you manually created the Gui on the server and parented it to the PlayerGui, it’s server-side. If you create the Gui on the client, it’s clientside. If it’s in StarterGui, it’s clientside because the client locally clones the contents of StarterGui each time the character spawns.

That said, you won’t have visibility issues client -> server – anything created by the server in a location visible to the client (i.e. not ServerStorage, ServerScriptService, or the server camera) is visible to the client. The only case this is not true is if you locally delete something on the client. It would then exist on the server, but not on the client. I don’t think that’s the issue here.

When you get an error from a LocalScript that tells you something doesn’t exist, it may mean it hasn’t loaded yet. Try using WaitForChild on those instances (both the buttons and the Value objects), and it should take care of the error. You should get the same error with FE on – it could just be that those instances just happened to be loaded when the script ran when you did your FE test.

The reason the teleport isn’t working when you don’t get an error is because of your gameid variable. You initialize it when the script runs (as soon as the Gui is created) when no options have been selected yet. Your gameid variable will always be 001 because those are the default options. If you move line 2 inside the onclicked function, it will be determined whenever the teleport button is clicked, and will have the correct options selected. You will not need the WaitForChilds in this case, because the buttons will already be loaded when the player clicks the Teleport button.

True, true. I feel pretty dumb.

However, when FilteringEnabled is turned on though, I have various parts of the menu setup to show changes. These don’t change though when FE is On, but do when FE is off. Any particular reason to why that could be? (I’m assuming you looked at the menu model file considering you called out the gameid variable being 001 and that it was created at Line 2, so you can look at the full files for the changing the text of each of these text labels in CarLabel, TrackLabel, and PlayerLabel)

1 Like

Just looked again, and it’s because the scripts updating those labels you have highlighted are scripts – not localscripts. Since the client is making changes to the value objects, those changes never replicate to the server with FE on, and the scripts never see the changes to their values.

Also, two tips:

The shortest wait time is wait() which defaults to wait(1/30). Anything shorter than that, and it just waits the same amount of time. Instead of wait(0), you can just use wait() because they wait the same amount of time.

Instead of:

while true do

you can do the following, as they have the same effect:

while wait() do

I. I am great at this scripting stuff. Ugg. It’s always the simple things, I swear. Thanks for the all the help.

1 Like

Don’t forget to mark that post as the solution. Hit the little checkbox button on Echo’s post.

1 Like

I’m all sorts of genius today.

starting 2018 off right


Use :WaitForChild() if it isn’t finding the frame. Also, ServerScripts will work in UIs.

Not while FE is On, I guess? Idk. I switched them to local and they work fine with FE on. (Yet now the problem I’m having, personally, is that all sorts of my places are marked Experimental even though FE is On, and Experimental Mode in Studio is off.)

1 Like

Server scripts work in UI while FE is on. The problem is they won’t see any changes made by local scripts, so you can’t mix and match them like you did in this case. I would suggest never using server scripts inside UI though – UI is local to each client, so you should use local scripts for any sort of UI.

1 Like