Module 8 · Roblox's object model
Creating an Instance correctly
Create, configure, mark, parent, and clean up a temporary object.
What you will learn
- Use Instance.new
- Configure before parenting
- Mark ownership and schedule cleanup
- parenting
- Assigning an Instance's Parent so it enters a hierarchy.
- attribute
- Custom typed data attached to an Instance.
Loading saved progress…
Understand
Read the idea and follow a worked example.
Why this matters
Coin Quest can create temporary markers while keeping their first visible state correct and making their ownership clear.
The mental model
Instance.new creates an unparented object. Configure its name, properties, and attributes first; assign Parent last so other systems see a ready object.
Temporary objects need a cleanup plan. Attributes can mark which system owns them.
New words and symbols
--!strict asks Studio to check your code for type mistakes. It is an instruction for the editor and produces no Output message.
Matching quotes such as "hello" surround a string: a piece of text. The quotation marks tell Luau where the text starts and ends.
local is read as “local”: it creates a name that is available only in the current code scope.
: is read as “colon”: it calls a method with the object supplied as the first receiver value.
= is read as “is assigned”: it evaluates the right side and stores that value in the name on the left.
. is read as “dot”: it accesses a named property or table field.
A tiny example
--!strictlocal Debris = game:GetService("Debris")local marker = Instance.new("Part")marker.Name = "QuestMarker"marker.Anchored = truemarker.Size = Vector3.new(2, 1, 2)marker:SetAttribute("CoinQuestOwned", true)marker.Parent = workspaceDebris:AddItem(marker, 10)Line by line
- 3
Debris provides scheduled Instance cleanup.
- 5
The Part starts without a parent.
- 6
A descriptive name is configured.
- 7
Anchored prevents physics movement.
- 8
Size is ready before visibility.
- 9
An attribute marks ownership.
- 10
Parent is assigned after configuration.
- 12
Debris schedules cleanup without a manual endless loop.
Read the code aloud
Read one statement at a time: name the value being read, what the operation does, and where its result goes. Keep identifiers exactly as written so you can find them again in the code.
Pause at calls, conditions, and loops. Explain when the body runs before moving to the next statement; use the line notes above when a symbol is unfamiliar.
Execution trace
Begin at the first executable statement. Comments and blank lines do not run; a branch chooses which block runs, and a loop may revisit its body.
Line 3: Debris provides scheduled Instance cleanup.
Line 5: The Part starts without a parent.
Line 6: A descriptive name is configured.
Line 7: Anchored prevents physics movement.
Line 8: Size is ready before visibility.
Line 9: An attribute marks ownership.
Line 10: Parent is assigned after configuration.
Line 12: Debris schedules cleanup without a manual endless loop.
State before and after
Before running, identify the starting values and any existing Studio objects this example needs. List what you expect to change.
After your practice change, check this result: The marker appears fully configured and is removed after the bounded lifetime.
Reading or printing a value leaves it unchanged. Look for assignments, calls that change state, and property updates to explain each change you observe.
Predict before running
Which assignment should happen after configuration?
Try it
Mark each step after you have tried it.
Common mistake
local marker = Instance.new("Part", workspace)Parenting during construction exposes default properties before configuration. Create unparented, configure, then assign Parent.
Checkpoint
Submit once you have considered every question. Retries are unlimited.
Recap
- Create unparented Instances.
- Configure before parenting.
- Mark ownership and plan cleanup.
Next: Next, you will configure position, size, color, and orientation datatypes.
Studio Companion
Not connected
Connect once. Compatible challenges will prepare automatically as you reach them.