- Filename
RoundConfig.lua- Class
ModuleScript- Studio location
ReplicatedStorage/RoundSystem/RoundConfig
--!strict
return {
intermissionSeconds = 10,
roundSeconds = 60,
}
- Filename
RoundService.server.lua- Class
Script- Studio location
ServerScriptService/RoundService
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local roundSystem = ReplicatedStorage:WaitForChild("RoundSystem")
local config = require(roundSystem:WaitForChild("RoundConfig"))
local stateEvent = roundSystem:FindFirstChild("RoundState")
if not stateEvent then
stateEvent = Instance.new("RemoteEvent")
stateEvent.Name = "RoundState"
stateEvent.Parent = roundSystem
end
local function countdown(phase, duration)
for remaining = duration, 0, -1 do
stateEvent:FireAllClients(phase, remaining)
task.wait(1)
end
end
while true do
countdown("Intermission", config.intermissionSeconds)
countdown("Round", config.roundSeconds)
end
- Filename
RoundHud.client.lua- Class
LocalScript- Studio location
StarterPlayer/StarterPlayerScripts/RoundHud
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local stateEvent = ReplicatedStorage
:WaitForChild("RoundSystem")
:WaitForChild("RoundState")
local screenGui = Instance.new("ScreenGui")
screenGui.Name = "RoundHud"
screenGui.ResetOnSpawn = false
screenGui.Parent = Players.LocalPlayer:WaitForChild("PlayerGui")
local label = Instance.new("TextLabel")
label.AnchorPoint = Vector2.new(0.5, 0)
label.Position = UDim2.fromScale(0.5, 0.04)
label.Size = UDim2.fromScale(0.34, 0.08)
label.BackgroundTransparency = 0.2
label.TextScaled = true
label.Parent = screenGui
stateEvent.OnClientEvent:Connect(function(phase, remaining)
label.Text = string.format("%s: %d", phase, remaining)
end)