Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I create a countdown GUI?

Asked by
Perci1 4988 Trusted Moderation Voter Community Moderator
10 years ago

I know how to make a gui count down. The problem is, every time you die the GUI resets. I need to make a timer for my group's fort, so all player's timers have to remain exactly the same, even after death.

for i = 100,1,-1 do
    wait(1)
    script.Parent.Text = tostring(i)
end

This makes the gui count down, but it still resets after death. Please help.

1 answer

Log in to vote
3
Answered by
Azarth 3141 Moderation Voter Community Moderator
10 years ago

Instead of controlling everyone's GUI from a single script, I like making everyone follow their own value, that way it's less laggy and less I have to worry about it.

-- Put a IntValue in Workspace, name it 'count'.

-- Put a script in ServerScriptService

local count = Workspace:WaitForChild("count")
for i = 100,0,-1 do 
    count.Value = i
    wait(1)
end

-- The script in the GUI

local label = script.Parent
local count = Workspace:WaitForChild("count")
count.Changed:connect(function()
    label.Text = count.Value
end)
0
That's a good idea, thank you. Perci1 4988 — 10y
Ad

Answer this question