Hey guys I want to create a countdown gui and when the countdown is at 00:00, all the players are killed and the countdown restart. Theres the script into the textlabel:
local rep = game:GetService("ReplicatedStorage")
local minutes = rep:WaitForChild("Minutes")
local seconds = rep:WaitForChild("Seconds")
local text = script.Parent
if seconds.Value <= 9 then
text.Text = tostring(minutes.Value)..":0"..tostring(seconds.Value)
else
text.Text = tostring(minutes.Value)..":"..tostring(seconds.Value)
end
minutes:GetPropertyChangedSignal("Value"):Connect(function()
if seconds.Value <= 9 then
text.Text = tostring(minutes.Value)..":0"..tostring(seconds.Value)
else
text.Text = tostring(minutes.Value)..":"..tostring(seconds.Value)
end
end)
seconds:GetPropertyChangedSignal("Value"):Connect(function()
if seconds.Value <= 9 then
text.Text = tostring(minutes.Value)..":0"..tostring(seconds.Value)
else
text.Text = tostring(minutes.Value)..":"..tostring(seconds.Value)
end
end)
and the script in ServerScriptService:
local rep = game:GetService("ReplicatedStorage")
local players = game:GetService("Players")
local minutesvalue = rep:WaitForChild("Minutes")
local secondsvalue = rep:WaitForChild("Seconds")
local minutes = 10 --minutes
local seconds = 0 --seconds
while true do
minutesvalue.Value = minutes
secondsvalue.Value = seconds
repeat
if secondsvalue.Value <= 0 then
minutesvalue.Value = minutesvalue.Value - 1
secondsvalue.Value = 59
else
secondsvalue.Value = secondsvalue.Value - 1
end
wait(1)
until secondsvalue.Value <= 0 and minutesvalue.Value <= 0
players.LocalPlayer.Character.Humanoid.Health = 0
end
Ty in advance and have a nice day!
