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

Beginning Timer Value help?

Asked by 4 years ago

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

2 answers

Log in to vote
0
Answered by 4 years ago

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! :)

Ad
Log in to vote
0
Answered by 4 years ago

You need to change 'timervar + 1' to:

timervar = timervar + 1

because it's adding 1 to nil.

:)

0
This also works, I think i should do timervar.value instead of just the variable alone. Thanks :D LargeMakesStuff 2 — 4y

Answer this question