- Filename
RoundTimer.server.lua- Class
Script- Studio location
ServerScriptService/RoundTimer
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local timerEvent = ReplicatedStorage:FindFirstChild("RoundTimerUpdate")
if not timerEvent then
timerEvent = Instance.new("RemoteEvent")
timerEvent.Name = "RoundTimerUpdate"
timerEvent.Parent = ReplicatedStorage
end
local INTERMISSION_SECONDS = 20
local ROUND_SECONDS = 90
local function countdown(phase, duration)
for remaining = duration, 0, -1 do
timerEvent:FireAllClients({
phase = phase,
remaining = remaining,
})
task.wait(1)
end
end
while true do
countdown("Intermission", INTERMISSION_SECONDS)
if #Players:GetPlayers() > 0 then
countdown("Round", ROUND_SECONDS)
else
timerEvent:FireAllClients({
phase = "Waiting for players",
remaining = 0,
})
task.wait(2)
end
end