๐ฏ GOAL:
Learn how to use more Lua keywords to make a trap, an automatic door, and a blinking warning light that plays a custom-recorded sound.
๐ง What Youโre Making Today:
An disappearing door that lets players through
A deadly floor trap
๐ง NEW KEYWORDS TO LEARN
๐น while
What it means:
Tells the computer to keep repeating something over and over โ like a loop โ until the computer is told to stop.
Say it out loud:
โKeep doing this until I say stop!โ
๐น ==
What it means:
Double equals, or equality. This asks if something is equal to something else. Itโs used when checking conditions and is great to use in โifโ statements It is not used for assigning values! Use it to check if a value is true or false or if two objects are the same.
Say it out loud:
โIs this thing the same as that thing?โ
๐น .Touched
What it means:
This runs code when something (like the player) touches the object. Touched will happen when anything touches the object, so youโll need to use โifโ and โ==โ to make sure the right things is touching the object.
Say it out loud:
โRun this part of the code when something touches it.โ
๐น .Transparency
What it means:
Controls how see-through a part is.
0 = solid
0.5 = half-visible
1 = invisible
Say it out loud:
โMake this part invisible or see-through.โ
๐น .CanCollide
What it means:
If set to false, players can walk through the part.
Say it out loud:
โCan I walk through this object or not?โ
๐ ๏ธ MINI PROJECTS
๐ช 1. Auto-Opening Door
Setup:
Add a large metal-looking Part and name it "Door"
Add a red button-looking Part and name it "DoorButton"Add a ClickDetector and a Script inside the DoorButton
Script:
local door = workspace.Door
function openDoor()
print("Opening door!")
door.Transparency = 0.5
door.CanCollide = false
end
script.Parent.ClickDetector.MouseClick:Connect(openDoor)
๐ 2. Floor Trap That Kills
Setup:
Add a flat black rectangle Part and name it "Trap"
Insert a Script inside it
Script:
function onTouch(other)
if other and other:FindFirstChild("Humanoid") then
print("Trap activated!")
other.Humanoid.Health = 0
end
end
script.Parent.Touched:Connect(onTouch)
๐ง Quiz Questions
You can only earn dad points if you can answer all of these:
What does while do in a script?
What does == mean?
What does .Touched let us do?
What happens when .Transparency is set to 1?
What does .CanCollide = false do?
๐ Parent Point Earned If:
Door opens with button click.
Trap kills the player when stepped on.
Your child explains all the new keywords clearly.
Your child passes the end-of-day quiz (can retry).