Timer for game bugging out, goes from 1:47 to 1:46 to 1:47 to 1:45 to 1:46 to 1:44

Title says it all, I’ll attach my code at the bottom. Basically the timer counts down on two player clients and for one client it only does this bug where it’ll count down from 2:00 then it goes 1:59 to 2:00 to 1:58 to 1:59 to 1:57 to 1:58 and so on.

Timer code:

local minutes = 2
	local seconds = 30
	
	repeat 
		if seconds <= 0 then
			minutes = minutes - 1
			seconds = 59
		else
			seconds = seconds - 1
		end
		if seconds <= 9 then
			plr.PlayerGui.Game.GameHUD.Timer.Text = tostring(minutes)..":0"..tostring(seconds)
		else
			plr.PlayerGui.Game.GameHUD.Timer.Text = tostring(minutes)..":"..tostring(seconds)
		end
		wait(1)
	until minutes <= 0 and seconds <= 0 or game.ReplicatedStorage.InRound.Value == false

Video:

1 Like

simple timer

local countdownLabel = script.Parent.ScreenGui.Frame.TextLabel
local minutes, seconds, formattedTime
local totalTime = 2 * 60 + 30

local function updateCountdown()
	minutes = math.floor(totalTime / 60) seconds = totalTime % 60
	formattedTime = string.format("%02d:%02d", minutes, seconds)

	countdownLabel.Text = formattedTime
	totalTime = totalTime - 1

	if totalTime < 0 then
		countdownLabel.Text = "Time's up!"
		return
	end
end

while true do
	task.wait(1)
	updateCountdown()
end
3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.