Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

textlabel text wont change?

Asked by 5 years ago

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?

2 answers

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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

1
Don't remind users to accept your answer. It is nature for the asker to accept it. It's just greedy. User#19524 175 — 5y
Ad
Log in to vote
0
Answered by
lunatic5 409 Moderation Voter
5 years ago
Edited 5 years ago

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!

Answer this question