I'm trying to make a 'Cash' variable that adds up over time. I don't think this is the right script, was a try though!
while true do
Cash = Cash + 5
Game.workspace.Part.SurfaceGUI.TextBox.Text = Cash
wait (20)
end
I'm trying to make a 'Cash' variable that adds up over time. I don't think this is the right script, was a try though!
while true do
Cash = Cash + 5
Game.workspace.Part.SurfaceGUI.TextBox.Text = Cash
wait (20)
end
A simple error: there was a space in between the wait and the parameter. This can easily be fixed by doing:
local Cash = 0
while wait(20) do
Cash = Cash + 5
game.workspace.Part.SurfaceGUI.TextBox.Text = tostring(Cash)
end
I also recommend you use a TextLabel and not a TextBox
Edit: I realized that the value would be a number value so you must make it a string for it to work. I provided that in the code above
Notes: 1. Lua doesn't care about the space; 2. Lua (and often Roblox) automatically converts numbers to strings for things like Text; 3. It should be game.Workspace or just workspace; 4. The critical issue was Cash not existing (which you did fix with line 1).
This discussion is preserved as it was. New answers, comments, and votes are closed.
5 comments
The script does add up the cash varaible. Do you mean changing the text of the SurfaceGUI?
yea changing the text
hmm try game instead of Game or just removing the game completely as that is not needed
... idk how that helps the SurfaceGUI work...
ik now its not textbox its textlabel. textboxes are for user input. textlabels are for display.