Lesson 01 of 05
Understanding Instances
The building blocks of Roblox — create, navigate, and manipulate the game hierarchy.
Instances are the fundamental objects in Roblox representing everything from Parts to Scripts. They form a hierarchical tree with game as the root.
Every Instance has
- Properties — attributes like Name, Position, Color, Transparency
- Methods — functions like :Destroy(), :Clone(), :FindFirstChild()
- Events — signals like .Touched, .ChildAdded, .Changed
Creating Instances: local part = Instance.new("Part") Always set the Parent LAST when configuring properties — this minimizes network replication.
Game hierarchy:
- game — root of everything
- workspace — 3D objects and characters
- ReplicatedStorage — shared assets (client + server)
- ServerStorage — server-only content
- ServerScriptService — server scripts
- Players — player management
Navigation methods:
- game.Workspace.Baseplate — dot notation (errors if missing)
- :FindFirstChild("name") — returns nil if not found
- :FindFirstChild("name", true) — recursive search
- :WaitForChild("name") — waits until it exists (client use)
- :IsA("ClassName") — check inheritance
luau
1-- Creating an Instance
2local part = Instance.new("Part")
3part.Name = "MyPart"
4part.Size = Vector3.new(4, 1, 4)
5part.Position = Vector3.new(0, 5, 0)
6part.BrickColor = BrickColor.new("Bright red")
7part.Anchored = true
8part.Parent = workspace -- set parent LAST
9
10-- Safe navigation
11local model = workspace:FindFirstChild("PlayerModel")
12if model then
13 local humanoid = model:FindFirstChildOfClass("Humanoid")
14 if humanoid then
15 print("Found humanoid with health:", humanoid.Health)
16 end
17end
18
19-- WaitForChild (safe on client)
20local gui = script.Parent:WaitForChild("ScreenGui")
21
22-- IsA for type checking
23local hit = workspace:FindFirstChild("Part")
24if hit and hit:IsA("BasePart") then
25 print(hit.Name .. " is a BasePart")
26end
27
28-- Clone and destroy
29local clonedPart = part:Clone()
30clonedPart.Position = Vector3.new(5, 5, 0)
31clonedPart.Parent = workspace
32-- part:Destroy() -- permanently removes
READY · 32 lines
