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 9 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:

local timerDebounce = false

game.ReplicatedStorage.GameInformation.Timer.Changed:connect(function(val)
    if timerDebounce then return end
    timerDebounce = true

    if val == 0 then
        game.ServerStorage.GameEvents.TimerEnded:Fire()
        game.ReplicatedStorage.RemoteEvents.TimerEnded:FireAllClients()
        timerDebounce = false
        return
    end

    val = val - 1
    wait(1)

    timerDebounce = false
    game.ReplicatedStorage.GameInformation.Timer.Value = val
end)
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 — 9y
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 — 9y

Answer this question