Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why doesn't this script work?

I am trying to make this script change the text of a sign to "Life" when you click the button for the gui

function onSelect()
game.Workspace.SignA.Board.Face.Contents.Text = Life

end

script.Parent.MouseButton1Click:connect(onSelect)

2 answers

Assuming everything else is correct:

function onSelect()
game.Workspace.SignA.Board.Face.Contents.Text = "Life" -- as life is a string, it needs to be surrounded by quotation marks. Otherwise this is setting the text to whatever is contained in the variable Life, which you have not defined.

end

script.Parent.MouseButton1Click:connect(onSelect)

function onSelect()
game.Workspace.SignA.Board.Face.Contents.Text = "Life" --Put it in quotes because it is a string. Like how you would type "print('Hello World')" and the "Hello World" is in quotes. If you do "Life" without quotes, lua would think there would be a variable named "Life". But since there isn't, It just Disconnects and in the output it would say, "Disconnected event because of exception".

end

script.Parent.MouseButton1Click:connect(onSelect)

This discussion is preserved as it was. New answers, comments, and votes are closed.