Timer not going fast (pls help)

You can write your topic however you want, but you need to answer these questions:
How do I make it so this timer goes faster and it doesnt go up by 3 seconds…?

The issue is it goes up by 3 seconds and I tried asking chatgpt cause I don’t know what to do (im not a good coder :upside_down_face: )

If someone could please help it would be appreciated

{{'pltimestart', 'starttime','timestart'},{'STARTS timer only for PL sb'},2,{},function(pl, args)
		local settingss = game.ReplicatedStorage.EPLSCOREBOARDSETTINGS

		if not settingss.TimerEnabled.Value then
			settingss.TimerEnabled.Value = true
			coroutine.wrap(function()
				while true do
					wait(5/15) -- Increased speed
					settingss.Timer.Value = settingss.Timer.Value + 1 -- Increment quickly
				end
				settingss.TimerEnabled.Value = false -- Reset on completion
			end)()
		else
			print("Timer is already running!") -- Feedback for overlapping
		end
	end},

yes this is using kohls admin aswel

local timerValue = game.ReplicatedStorage.EPLSCOREBOARDSETTINGS.Timer
local textLabel = script.Parent

while true do
– Get the current timer value
local currentTime = timerValue.Value

-- Stop the timer at specific points
if currentTime == 45 or currentTime == 90 or currentTime == 105 or currentTime == 120 then
	wait() -- Stops updating until the value changes
else
	-- Convert the timer value into minutes and seconds
	local minutes = math.floor(currentTime / 60)
	local seconds = currentTime % 60

	-- Format the time as MM:SS
	textLabel.Text = string.format("%02d:%02d", minutes, seconds)
end

wait(1) -- Update every second

end also here it is on the gui side

can u explain the issue i dont get it, is the timer slow?

1 Like

This loop would technically never end, which might be a problem in the future(?).
You might want to look into replacing the while true do,
with while settingss.TimerEnabled.Value == true do.
It is also using wait(), which should probably be replaced with a task.wait() for higher accuracy.

This is because your loop inside the custom command function increases the value runs 3 times per second (wait(5/15) = 0.333s), and the loop inside the GUI updates once per second (wait(1)).
This means the value increases 3 times a second, then the GUI updates, which indeed shows that the timer has counted up 3 times.


Using a loop in the GUI is not necessary. You might want to look into using the .Changed event instead:

local timerValue = game.ReplicatedStorage.EPLSCOREBOARDSETTINGS.Timer
local textLabel = script.Parent

timerValue.Changed:Connect(function(currentTime)
    if currentTime == 45 or currentTime == 90 or currentTime == 105 or currentTime == 120 then
      -- Do what you need to highlight the timer, play a sound maybe?
    end
    -- Convert the timer value into minutes and seconds
    local minutes = math.floor(currentTime / 60)
    local seconds = currentTime % 60
    
    -- Format the time as MM:SS
    textLabel.Text = string.format("%02d:%02d", minutes, seconds)
end)

Thanks for the help, I definetly overlooked this :sweat_smile: