This is a timer that counts from 300 to 0. I intended to have a wait() of 1, but when I used that, each second was around 3 seconds (I compared it to Google timers).
What is with this delay?
workspace.TimerOn.Changed:connect(function() for timer = 300, 0, -1 do if workspace.TimerOn.Value == true then script.Parent.Text = tostring(timer) wait(0.25) -- I changed the wait to 0.25 to correct the time end end end) script.Parent.Changed:connect(function() if game.Workspace.TimerOn.Value == true and script.Parent.Text == "0" then -- fire an event when timer is at 0 end end)
Try this custom wait(), which utilizes tick() - it may be more accurate:
local function custom_wait(seconds) local current = tick() local goal = seconds+current while tick()<=goal do wait(.00005) end return end