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

Why doesn't this script work?

Asked by
Danfly 5
10 years ago

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

Log in to vote
0
Answered by 10 years ago

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)

Ad
Log in to vote
0
Answered by 10 years ago
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)

Answer this question