Im trying to make it so when you click a button, it makes it so text changes. But it's not working. The text just stays the same. Script:
script.Parent.MouseButton1Click:connect(function) game.StarterGui.ScreenGui2.Frame.TextLabel.Text = "You are now a zombie" end)
But it won't change. Any help?
First of all, let's lay down a few things. "connect" might become deprecated. Use "Connect" instead. Second, function looks like: "(function()" not "(function)". As to answer your question, the reason this isn't working is that when the game starts, everything in StarterGui gets cloned to PlayerGui, so you have to edit PlayerGui, not Starter. To fix everything, put this in a localscript in the button.
script.Parent.MouseButton1Click:Connect(function() game.Players.LocalPlayer.PlayerGui.ScreenGui2.Frame.TextLabel.Text = "You are now a zombie" end)
If this helps, make sure to accept my answer and upvote me! :D
First of all, this code should be in a LocalScript inside of the button. Second, connect
is deprecated. Use Connect
instead. Also, you typed "(function()" incorrectly. It shouldn't be "(function)", it should be "(function()". Finally, GUIs shouldn't be changed with a server-side script. Here is what your code should look like:
script.Parent.MouseButton1Click:Connect(function() script.Parent.Parent.TextLabel.Text = "You are now a zombie" end)
The "script.Parent.Parent.TextLabel" part of the code may not be correct, as I do not know where the TextLabel is located. If that isn't where the TextLabel is located in reference to the script, change it to the correct location. Anyway, I hope this helps! Good luck!