GUI stands for "Graphical User Interface" - it's the stuff players see on their screen, like health bars and timers!
| Property | Value |
|---|---|
| Name | TimerLabel |
| Size | {0.3, 0}, {0.1, 0} |
| Position | {0.35, 0}, {0.05, 0} |
| Text | 30 |
| TextScaled | ✓ (checked) |
| BackgroundTransparency | 0.5 |
Now we need a script to make the timer count down. Add a Script to ServerScriptService (NOT inside the GUI).
-- Timer Script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
-- Create a value all players can see
local timerValue = Instance.new("IntValue")
timerValue.Name = "GameTimer"
timerValue.Value = 30
timerValue.Parent = ReplicatedStorage
-- Countdown function
local function startCountdown(seconds)
for i = seconds, 0, -1 do
timerValue.Value = i
wait(1)
end
print("Timer finished!")
end
-- Wait for game to load, then start
wait(3)
startCountdown(30) Add a LocalScript inside the TimerLabel to update the display:
-- Update timer display
local label = script.Parent
local ReplicatedStorage = game:GetService("ReplicatedStorage")
-- Wait for the timer value to exist
local timerValue = ReplicatedStorage:WaitForChild("GameTimer")
-- Update whenever it changes
timerValue.Changed:Connect(function(newValue)
label.Text = tostring(newValue)
-- Make it red when time is low!
if newValue <= 5 then
label.TextColor3 = Color3.fromRGB(255, 0, 0)
else
label.TextColor3 = Color3.fromRGB(255, 255, 255)
end
end)