← Back to All Parts
Part 510 min

Mini-Project 2 - Countdown Timer

Your game needs two timers: a 5-second countdown at the start, and a 30-second chase timer. Let's learn how to make timers that everyone can see!

Step 1: Create a Screen GUI

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

Step 2: Create the Timer Script

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)

Step 3: Make the Label Show the Timer

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)

Scripts vs LocalScripts - Important!

Script
Runs on the server (controls the game)
LocalScript
Runs on each player's screen (shows things)
This part is tricky! Ask for help if you get confused!

✅ Checklist - Check them off!

A real countdown timer! It counts down and turns red when time is low!