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

Why does my timer not always work?

Asked by 10 years ago

Hello,

I have a script that controls an 'IntValue' as if it were a timer. This Timer is in 'ReplicatedStorage' under a 'Configuration'. When the timer hits zero, it is supposed to fire a 'BindableEvent' as well as a 'RemoteEvent'. However, for some reason, at seemingly random times, the 'scripts' that rely upon those 'Bindable' and 'Remote' 'events' freeze. They just don't execute the code they are supposed to when the timer goes off. This happens maybe 10% of the time.

Here is my 'script' that controls the Timer:

01local timerDebounce = false
02 
03game.ReplicatedStorage.GameInformation.Timer.Changed:connect(function(val)
04    if timerDebounce then return end
05    timerDebounce = true
06 
07    if val == 0 then
08        game.ServerStorage.GameEvents.TimerEnded:Fire()
09        game.ReplicatedStorage.RemoteEvents.TimerEnded:FireAllClients()
10        timerDebounce = false
11        return
12    end
13 
14    val = val - 1
15    wait(1)
16 
17    timerDebounce = false
18    game.ReplicatedStorage.GameInformation.Timer.Value = val
19end)
0
The changed event passes a property argument not a value argument. Try setting a variable as 'local val = timer.Value' or something like that. And when you're changing the timer's value, you will need to do 'timer.Value = timer.Value - 1' Tkdriverx 514 — 10y
2
Not true for any of the "___Value" objects. For things like IntValue, StringValue, ObjectValue, etc., the argument is actually the new value. NoahWillCode 370 — 10y

Answer this question