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

How to add numbers to my surface gui?

Asked by 6 years ago
Edited 6 years ago

I created a Brick where once you step on it, it adds a 1 to a surface GUI. I'm stuck on how to have it add by 1 each time. So you step on it and it goes to "1", and the next time you step on it the surface gui goes to "2"

But as of right now it only goes to "1" any help?

function onTouch(hit)
game.Workspace.SurfaceGui.SurfaceGui.TextLabel.Text =  1
end


script.Parent.Touched:connect(onTouch)

1 answer

Log in to vote
1
Answered by 6 years ago
Edited 6 years ago

So it is just displaying 1 because it is adding to nothing! Easy fix, this should work

local val = 0
function onTouch(hit)
local num = val + 1
game.Workspace.SurfaceGui.SurfaceGui.TextLabel.Text = num
end


script.Parent.Touched:connect(onTouch)
Ad

Answer this question