Question About Timer

Hi Everyone!
My Question is Is there any way to make This Timer The Same time for Everyone who will join or who will be in server

server timer

Like Tower Of Hell’s Timer btw Timer’s Script is in Script and everything is working fine but the problem is when player joins Its reseting the timer.

2 Likes

You can use a Script in serverscriptstorage and relay the information to the localuser or just use a script in the GUI to count down

1 Like

The Timer is Working with Script in it But When other player joins the gui is not the same for all

1 Like

I recommend so you create a string value inside of replicated storage and change this value by a script. Then all you have to script on the client is that you have to read this value once changed and it’s going to update based on server’s increase or decrease.

1 Like

So the timer Text will be that string value? if yes i am so bad at strings that they are numbers i think i cant do it

1 Like

set the textlabel’s text in the starter gui and then fire to all clients and have a script in the gui listen for the clientevent and have it update the textlabel’s text for them.

1 Like

I think you can use a remote event and fire all clients every second.

1 Like

First, create value like this

image

You can use this code to change the counter value:

function StartCounter()
	local CounterString = game.ServerStorage.Counter
	local Counter = 10 * 60 --10 Minutes
	
	spawn(function()
		while wait(1) do
			Counter = Counter - 1
			
			CounterString.Value = string.format("%d:%02d", math.floor(Counter/60), Counter%60)
			
			--Fire all clients to change the counter UI or something idk...
			
			if (Counter <= 0) then				
				break -- End the loop and wait till the next call
			end
		end
	end)
end

Basically, everytime the round starts, call StartCounter() and the counter will start to change, everytime It changes, replicate It across all clients.

If you want to know a little bit more about string.format() check this page about string formatting and converting

Thank you For This info Can i ask another question please how do i learn that thing that ou wrote %d:%02d what that means i dont understand it

Edit: Oh sorry i just saw the link and understood Thank you so much it will be helpfull.

1 Like

%d:%02d is a String Pattern that you can use for formating the raw counter value to a “time” format. I picked It up from a post I found on the devforum and if I’m not wrong, %d returns any type of number that we input after the string.

Basically the first %d is equal to the second parameter of string.format, math.floor(Counter/60), and the second %02d" is equal to Counter%60.

2 Likes