Timer GUI desynced from other players?

Hello! When playing with a different player, the timer is wildly different from each other. For example, I have 100 seconds and they have 125 seconds. The script below is handled like this:
image

local time = workspace.timer.Value
local gui = script.Parent
local folder = workspace.PlayerIngameFolder
local teleport = workspace.UUTeleport
gui.Text = time

while true do
	if time ~= 0 then
		teleport.Enabled = true
		time -= 1
		wait(1)
		gui.Text = time
	elseif time == 0 then
		teleport.Disabled = true
		print(#workspace.PlayerIngameFolder:GetChildren())
		gui.Text = "Round Ended! " .. #workspace.PlayerIngameFolder:GetChildren() .. " winners!"
		wait(3)
		gui.Text = "Intermission.."
		wait(3)
		gui.Text = "Round Starting"
		wait(3)
		time = 180
		gui.Text = time
	end
end

The script below handles the timer in workspace.
image

local time = script.Parent.Value
while true do
	if time ~= 0 then
		time -= 1
		wait(1)
		--gui.Text = time
	elseif time == 0 then
		--gui.Text = "Round Ended! " .. #workspace.PlayerIngameFolder:GetChildren() .. " winners!"
		wait(3)
		--gui.Text = "Intermission.."
		wait(3)
		--gui.Text = "Round Starting"
		wait(3)
		time = 180
		--gui.Text = time
	end
end

Why does this happen? Thanks in advance!

Why are you even using a time variable if you already have a timer instance? That’s probably causing the desync. You’re also setting time instead of time.Value.

Server code:

local timer = script.Parent
while true do
	if timer.Value ~= 0 then
		timer.Value -= 1
		wait(1)
		--gui.Text = timer.Value
	elseif timer.Value == 0 then
		--gui.Text = "Round Ended! " .. #workspace.PlayerIngameFolder:GetChildren() .. " winners!"
		wait(3)
		--gui.Text = "Intermission.."
		wait(3)
		--gui.Text = "Round Starting"
		wait(3)
		timer.Value = 180
		--gui.Text = timer.Value
	end
end

Client Code:

local timer = workspace.timer
local gui = script.Parent
local folder = workspace.PlayerIngameFolder
local teleport = workspace.UUTeleport

timer.Changed:Connect(function(newValue)
	gui.Text = newValue
	
	if newValue > 0 then
		teleport.Disabled = false
	else
		teleport.Disabled = true
		
		print(#workspace.PlayerIngameFolder:GetChildren())

		gui.Text = "Round Ended! " .. #workspace.PlayerIngameFolder:GetChildren() .. " winners!"
		task.wait(3)

		gui.Text = "Intermission.."
		task.wait(3)

		gui.Text = "Round Starting"
	end
end)

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