Within my round sequence, I am trying to run an event at a particular time. However, my programming knowledge is a bit lacklustre, and my only thinking is to create an if statement at a particular time. When I do this, though, nothing happens (e.g., if i == 150 then [call event]). Therefore, I am wondering what I can do to achieve this and where I should call it.
Script for Critique:
-- There is coding that runs before this loop
local RoundTime = 300 -- How long the map will remain in the workspace
for i = RoundTime, 0, -1 do
Status.Value = "The Agents must Terminate the MALWARE within the Time Limit"
local Mactive = false
local Agents = {}
for i, Player in pairs(game.Players:GetPlayers()) do
if Player:FindFirstChild("Agent") then
table.insert(Agents, Player)
elseif Player:FindFirstChild("MALWARE") then
Mactive = true
end
end
if not Mactive then
Status.Value = "The Agents have terminated the MALWARE!"
Round.AgentVictory()
task.wait(5)
break
end
if #Agents == 0 then
Status.Value = "The MALWARE has Eliminated the Agents!"
Round.MALWAREVictory()
task.wait(5)
break
end
if i == 0 then
Status.Value = "The Agents have Failed to Terminate the MALWARE within the Time Limit!"
Round.Stalemate()
task.wait(5)
break
end
Timer.Value = toMS(i)
task.wait(1)
end
-- End of code of a larger game sequence