I have a for loop that runs the round timer.
The round can end by 3 things happening
- Red team loses all tickets
- Blue team loses all tickets
- Time runs out
But what if number 1 or 2 happens and there is still time on the clock. Well thats where my problem is occurring.
I have a remote even that fires when either team has 0 tickets and it does fire, but it doesnt change the number in the for loop.
So here is the for loop code, I figured thats all the code you need because it is firing the code but the code just isnt doing anything.
Heres the for loop code.
-- Starts round timer
for i = RoundTime, 0, -1 do
local function onTimerResetEventFired()
print("TimerResetFired")
RoundTime = 3
print(RoundTime)
end
Status.Value = "10 MINUTES LEFT"
if i <= 540 then
Status.Value = "9 MINUTES LEFT"
end
if i <= 480 then
Status.Value = "8 MINUTES LEFT"
end
if i <= 420 then
Status.Value = "7 MINUTES LEFT"
end
if i <= 360 then
Status.Value = "6 MINUTES LEFT"
end
if i <= 300 then
Status.Value = "5 MINUTES LEFT"
end
if i <= 240 then
Status.Value = "4 MINUTES LEFT"
end
if i <= 180 then
Status.Value = "3 MINUTES LEFT"
end
if i <= 120 then
Status.Value = "2 MINUTES LEFT"
end
if i <= 60 then
Status.Value = i.." SECONDS LEFT"
end
if i == 0 then
Status.Value = "ROUND OVER!"
for _, Player in pairs(game.Players:GetChildren()) do
Player.Backpack:ClearAllChildren()
Player.Character.Humanoid:UnequipTools()
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
if Player.Character:FindFirstChildOfClass("Tool") then
Player.Character:FindFirstChildOfClass("Tool"):Destroy()
end
end
wait(3)
end
TimerReset.OnServerEvent:connect(onTimerResetEventFired)
wait(1)
end
I know its inefficient but anyways whenever the code fires it sets the timer to 3 for a split second then it goes back to its old number where it left off.
Any one have any ideas? Thank you for your time :)
[UPDATE] My current code is this, but it still doesnt work any other ideas?
TimerReset.OnServerEvent:connect(function()
TimerReset = true
print("Fired")
print(TimerReset)
end)
-- Starts round timer
for i = RoundTime, 0, -1 do
if TimerStop == true then
break
end
Status.Value = "10 MINUTES LEFT"
if i <= 540 then
Status.Value = "9 MINUTES LEFT"
end
if i <= 480 then
Status.Value = "8 MINUTES LEFT"
end
if i <= 420 then
Status.Value = "7 MINUTES LEFT"
end
if i <= 360 then
Status.Value = "6 MINUTES LEFT"
end
if i <= 300 then
Status.Value = "5 MINUTES LEFT"
end
if i <= 240 then
Status.Value = "4 MINUTES LEFT"
end
if i <= 180 then
Status.Value = "3 MINUTES LEFT"
end
if i <= 120 then
Status.Value = "2 MINUTES LEFT"
end
if i <= 60 then
Status.Value = i.." SECONDS LEFT"
end
if i == 0 then
Status.Value = "ROUND OVER!"
for _, Player in pairs(game.Players:GetChildren()) do
EndGameLost:FireClient(Player)
end
wait(3)
end
wait(1)
end

3 comments
How come you dont do, If timerReset == true then break end
This is so the for loop timer breaks (exits) when the remote event has fired
It doesnt work heres a link to my new code on CodeShare.io https://codeshare.io/aJ6PMK