🎯 GOAL:
Build a mini “escape room” where the player must reach a safe zone before time runs out, or the game resets!
🔧 What You’re Making Today:
A countdown timer with Heads-Up Display (HUD)
Safe zone detection
A reset button
🧠NEW KEYWORDS TO LEARN
🔹 tick()
What it means:
Gets the current time in seconds. Used to measure how much time has passed.
Say it out loud:
“Remember what time it is right now.”
🔹 math.floor()
What it means:
Rounds a number down. Good for showing time as a whole number (like 3 instead of 3.25).
Say it out loud:
“Get rid of the decimals.”
🔹 ScreenGui & TextLabel
What it means:
Used to display text on the screen like a countdown or message.
Say it out loud:
“Show something on the screen for the player.”
🔹 Restarting the Game
We’ll simulate a "reset" by teleporting the player back and restarting the timer.
🛠️ MINI PROJECTS
⏲️ 1. Countdown Timer with HUD
Setup:
Add a ScreenGui to StarterGui
Inside it, add a TextLabel named "CountdownLabel"
Script (StarterPlayerScripts or LocalScript):
local timeLimit = 15 -- seconds
local startTime = tick()
local label = script.Parent:WaitForChild("CountdownLabel")
while true do
local timeLeft = timeLimit - (tick() - startTime)
if timeLeft <= 0 then
label.Text = "Time’s up!"
break
else
label.Text = "Time Left: " .. math.floor(timeLeft)
end
wait(0.1)
end
🧠 Change timeLimit to make the game harder or easier.
🏃♂️ 2. Safe Zone Detection
Setup:
Add a green Part named "SafeZone"
Set Transparency = 0.5, CanCollide = false
Add a Script to SafeZone
Script:
local startTime = tick()
local timeLimit = 15
local safeZone = script.Parent
function onTouch(playerPart)
local character = playerPart.Parent
if character:FindFirstChild("Humanoid") then
local timeTaken = tick() - startTime
if timeTaken <= timeLimit then
print("You escaped in time!")
else
print("Too slow! Game will restart.")
character:MoveTo(Vector3.new(0, 5, 0)) -- send player back
end
end
end
safeZone.Touched:Connect(onTouch)
🧹 3. Optional Reset Button
Setup:
Add a small Part called "ResetButton"
Add a ClickDetector and Script
Script:
function onClick(player)
if player.Character then
player.Character:MoveTo(Vector3.new(0, 5, 0)) -- restart spot
end
end
script.Parent.ClickDetector.MouseClick:Connect(onClick)
🧠 Quiz Questions
You can only earn dad points if you can answer all of these:
What does tick() do?
Why do we use math.floor() with the timer?
What does a TextLabel do on screen?
What happens if the player reaches the safe zone after time runs out?
How could you make this escape game harder?
🏅 Dad Point Earned If:
Countdown timer shows on screen
Player can escape before time is up
Game “resets” if player is too slow
Your child answers all 5 quiz questions