I'm a beginner scripter, and i'm trying to create a timer from scratch (without any tutorials). When I try to add to the timervar, i get error "Expected '=' when parsing assignment. Got '+'"
Anything I did wrong? It does loop every second but it wont allow me to add to the variable. Thanks
timervar = game.ServerScriptService.Script.Timer.Value while true do wait(1) timervar + 1 print(timervar) end
In line 1, when you mention the Value
property, the timeVar
will only store the number, not the Value object itself. To add the value by 1, you need to get the Value
property, and set it equal to itself + 1.
timervar = game.ServerScriptService.Script.Timer -- Don't mention the Value property. while true do wait(1) timervar.Value = timervar.Value + 1 print(timervar.Value) end
I hope this will help. Keep practising! :)
You need to change 'timervar + 1' to:
timervar = timervar + 1
because it's adding 1 to nil.
:)