Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I make a GUI timer that does not reset when a new player joins?

I made a GUI timer that works, but when someone rejoins or joins the game, the timer for that person resets while for others the timer remains as it is.

How do I make a timer that displays what value it is on when a new player joins instead of reseting back to 60 for that person?

1 answer

✓ Accepted answer

I would use a NumberValue in ReplicatedStorage that acts as the timer. For every second that passes, you can change its Value from a server script, and listen to the .Changed of the value from the local scripts to update the gui. This way, when a player joins, their script will pick up the change and update their gui to be synced with the others.

For example, if there was a NumberValue called Timer in ReplicatedStorage, you could do this in a server script:

local Timer = 1
while true do
	game.ReplicatedStorage.Timer.Value = Timer
	Timer = Timer + 1
	wait(1)
end	

And in a LocalScript inside the gui:

game.ReplicatedStorage.Timer.Changed:Connect(function(NewVal)
	script.Parent.Text = "time passed: " .. NewVal
end)

Which should keep all clients up-to-date, regardless of when they join.

2 comments

0

Thanks! It does not let me to accept your answer for some odd reason..

0

nvm

This discussion is preserved as it was. New answers, comments, and votes are closed.