I got some code already, but I see some errors and don't know why. For my 30 sec countdown, when it reaches zero I want all the players to change to red colored team then die. For my 2 min countdown, when it reaches zero I want them to change to blue colored team then die. I did this, but it does not really work. Can you please help my script and tell me if I put it in workspace or where? And tell me if its a local script or script? I get really confused. Thank you!



local seconds = 120 -- 120 seconds, meaning 2 minutes.

local seconds2 = 30 -- My 30 sec one
local timer = script.Parent -- Timer object!

seconds = ((seconds > 1 and seconds) or 1)

 

function startTimer()

local begin = tick()

while tick() < begin + seconds do

local diff = (math.floor(tick()) - (begin + seconds))

timer.Text = math.floor(seconds / 60) .. ":" .. (seconds % 60)
wait(0.1)
end
for k,v in pairs(game:service("Players"):GetPlayers()) do
if v.Character and v.Character:FindFirstChild("Humanoid") then
v.Character:FindFirstChild("Humanoid").Health = 0
end
end
 
function startTimer2()
local begin = tick()

while tick() < begin + seconds do

local diff = (math.floor(tick()) - (begin + seconds))

timer.Text = math.floor(seconds2 / 60) .. ":" .. (seconds2 % 60)

wait(0.1)

end

for k,v in pairs(game:service("Players"):GetPlayers()) do

if v.Character and v.Character:FindFirstChild("Humanoid") then

v.Character:FindFirstChild("Humanoid").Health = 0

end

end
 
 

while true do

startTimer()

startTimer2()

end

5 comments

0

#Don'tUseFreeModels

0

She might be using free models to learn scripting.

0

Your seconds2 variable is likely treating 2 as a value rather than part of the name, change it to something like Seconds or SECONDS. Do the same for everything with 2 that you made.

0

Free models are bad if you don't examine code. They could be logging all your game's hierarchy to tell how you built it, and be messing with DataStores.

0

That's why they don't auto update :P. Don't want them to update it to a studio virus.