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

How to add numbers to my surface gui?

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

✓ Accepted answer

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)

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