Help with Round Timer

So I made a timer in my game, and it does work. But I need something with a RemoteEvent, and a normal script in ServerScriptService, so that when a player joins after a server starts, the timer does not restart for the player, and the timer for all players is different. How can I do that, and not prevent that?

Here is my Script in my Text btw:

local timer = script.Parent
local seconds = 0
local minutes = 5

repeat
	if seconds <= 0 then
		minutes = minutes - 1
		seconds = 59
	else
		seconds = seconds - 1
	end
	
	if seconds < 9 then
		timer.Text = tostring(minutes)..":0"..tostring(seconds)
	else
		timer.Text = tostring(minutes)..":"..tostring(seconds)
	end
	wait(1)
until minutes <= 0 and seconds <= 0

Help soon,

papahetfan

2 Likes

Is the timer in the workspace and server side? If it is then I don’t see why some players would see a different time since there is only 1 time on the server.

Unless the timer or it’s script is run on the client I don’t see any issues

Make it a server script in server script service.

i don’t really understand what you want but i think is something like this you want:

Script Server:

local PlayerTime = Instance.new("Folder") -- Create folder where player time will be stored
PlayerTime.Name = "PlayerTime"
PlayerTime.Parent = game:GetService("ReplicatedStorage")

game.Players.PlayerAdded:Connect(function(Player) -- player added
	
	local PlayerTimer = Instance.new("NumberValue") -- added player timer
	PlayerTimer.Name = Player.Name
	PlayerTimer.Value = 300 -- 300 = 5min set timer
	PlayerTimer.Parent = PlayerTime
	
	
end)

game.Players.PlayerRemoving:Connect(function(Player) -- player removed
	
	if PlayerTime:FindFirstChild(Player.Name) then -- if find player timer destroy the timer
		
		PlayerTime[Player.Name]:Destroy()
		
	end
	
end)

while wait(1) do -- every 1 second remove 1 seconde to every player timer
	
	for i,v in pairs(PlayerTime:GetChildren()) do
		
		if v.Value == 0 then
			
			game.Players[v.Name]:Kick("Timer ended") -- if timer is 0 the player get kick
			
		end
		
		v.Value -= 1
		
	end
	
end

Local Script:

local Player = game:GetService("Players").LocalPlayer
timer = script.Parent

local function UpdateText() -- function
	
	local Value = game:GetService("ReplicatedStorage"):WaitForChild("PlayerTime")[Player.Name].Value
	local seconds = 0
	local minutes = 0
	
-- convert to minute your script

	repeat wait()
		
		if Value >= 60 then
			
			Value -= 60
			minutes += 1
			
		else
			
			seconds = Value
			Value -= Value
			
		end
		
	until Value == 0
	
	if seconds < 9 then
		timer.Text = tostring(minutes)..":0"..tostring(seconds)
	else
		timer.Text = tostring(minutes)..":"..tostring(seconds)
	end 
	
end

repeat wait() until game:GetService("ReplicatedStorage"):WaitForChild("PlayerTime"):FindFirstChild(Player.Name)

game:GetService("ReplicatedStorage"):WaitForChild("PlayerTime") [Player.Name]:GetPropertyChangedSignal("Value"):Connect(function() -- every time player value change in playertime folder
	
	UpdateText()
	
end)

UpdateText() -- game start

You can use this for convert minute to second : minute to second - Google Search