im new to scripting and im trying to make a timer. on the last line of this script, there is an error saying Players.Swolcu.PlayerGui.ScreenGui.TextBox.Script:13: bad argument #3 to 'Text' (string expected, got nil)
debounce = true function b() if debounce == true then debouce = false wait (1) timeS = (timeS + 1) end debounce = true end script.Parent.Text = (timeS)
how come there needs to be a string even thought i put brackets
thanks!
There are two problems with your script.
timeS is local to the b function, so outside of that function it will be nil.
You never call the b function anywhere, so the code there never runs.
To create a simple timer like that you can just do something like this:
local timeS = 0 while true do timeS = timeS + 1 script.Parent.Text = tostring(timeS) wait(1) end
If you want other code to run after this, you can wrap it in a spawn
spawn(function() local timeS = 0 while true do timeS = timeS + 1 script.Parent.Text = tostring(timeS) wait(1) end end) -- Other code here