This Timer gets sent a time once at the start of a round. Sometimes it works perfectly in sink with 1 second per count, but other times it hops down 2 at a time. Why does the time sometimes hop and start counting down 2 at a time? It sometimes finishes twice as fast as the server.

The timer starts counting down too fast and hopping through numbers, even though I asked it to wait(1)

local plr = game.Players.LocalPlayer
local mod = require(plr.PlayerScripts.ClientModule)
local Time = script.Parent.Time
local gTime;

game.ReplicatedStorage.Remotes.Timer.OnClientEvent:Connect(function(gtime)
	gTime = gtime
	while mod.GameState ~= 2 and gTime >= 0 and wait(1) do --gamestate value (1 = Playing; 2 = Lobby, 3 = Spectator)
		if gTime < 60 then
			Time.TextA.Text = gTime
			Time.TextB.Text = gTime
		end
	
		if gTime > 59 then
			if (gTime % 60) < 10 then
				Time.TextA.Text = math.floor(gTime / 60) .. ":0" .. math.floor(gTime % 60)
				Time.TextB.Text = math.floor(gTime / 60) .. ":0" .. math.floor(gTime % 60)
			elseif (gTime % 60) > 9 then
				Time.TextA.Text = math.floor(gTime / 60) .. ":" .. math.floor(gTime % 60)
				Time.TextB.Text = math.floor(gTime / 60) .. ":" .. math.floor(gTime % 60)
			end
		end	
		gTime = gTime - 1
	end
end)

2 comments

0

Maybe you are calling the event more than once.

0

ive had a lot of issue with wait() it may be do to server lag or lag in general