✓ Accepted answer
Original Answer
The easiest way I can think of doing this would be to clone a GUI into every character that spawns, while keeping the time in a server script. Put this in a script that is in the workspace, and a gui in the script:
local gui = script.TextLabel
local time = 120
for i = 1, 120 do
wait(1)
time = time - 1
end
game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(character)
gui:Clone().Parent = player.PlayerGui
gui.Text = tostring(time)
end)
end)
You're countdown script will now count down from 120 to 0 once while putting a GUI on you're screen each time you re spawn.
Resetting and Reapplying
The best way to do this, in my opinion, would be to make the original countdown script itself a function. Then, when the function is called, it will start the countdown.
local gui = script.TextLabel
local time = 120
function countdown()
for i = 1, 120 do
wait(1)
time = time - 1
end
game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(character)
gui:Clone().Parent = player.PlayerGui
gui.Text = tostring(time)
if time == 0 then
gui:Destroy()
wait()
time = 120
end
end)
end)
end
countdown()
Now, you can add on anything to this script and just call the function countdown when you want the countdown to start.
3 comments
What's the purpose of this script?
the only way that you could create a global countdown would be to make this a server script and have some way that each player would receive the value from the script
Can you tell me the script golden?