Module 8 · Roblox's object model
Instances, properties, methods, and events
Name four different ways code relates to Roblox objects.
What you will learn
- Define an Instance
- Distinguish a property, method, and event
- Instance
- A Roblox object that can live in the DataModel hierarchy.
- property
- A named value describing an object.
- event
- A signal announcing that something happened.
Loading saved progress…
Understand
Read the idea and follow a worked example.
Why this matters
A Coin Quest door has data you can read, actions you can request, and signals you can respond to. Confusing those categories leads to unclear code.
The mental model
An Instance is the object. A property is data on it, such as Name. A method is behavior called with a colon, such as FindFirstChild. An event is a signal, such as Touched.
Read the punctuation: dot for a property, colon and parentheses for a method call, and later :Connect() on an event.
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.
print(...) calls the built-in print function. Put the values to show inside its parentheses; separate multiple values with commas. Read the result in Studio's Output panel.
local is read as “local”: it creates a name that is available only in the current code scope.
if is read as “if”: it starts a decision by evaluating a condition.
then is read as “then”: it marks the body that can run when the condition is truthy.
end is read as “end”: it closes a block such as a decision, loop, or function.
: 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.
A tiny example
--!strictlocal platform = workspace:FindFirstChild("Platform")if platform and platform:IsA("BasePart") then print(platform.Name, platform.Anchored, platform.Touched)endLine by line
- 3
FindFirstChild is a method called on workspace.
- 5
IsA is another method and refines the object's class.
- 6
Name and Anchored are properties; Touched is an event value. Printing the event does not connect to it.
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: FindFirstChild is a method called on workspace.
Line 5: IsA is another method and refines the object's class.
Line 6: Name and Anchored are properties; Touched is an event value. Printing the event does not connect to it.
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: You can classify each member by what it represents and how code uses it.
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 category is Anchored?
Try it
Mark each step after you have tried it.
Common mistake
platform:Anchored()Anchored is a boolean property, not a method. Read or assign it with dot syntax.
Checkpoint
Submit once you have considered every question. Retries are unlimited.
Recap
- Instances are hierarchy objects.
- Properties store object data.
- Methods perform actions and events signal occurrences.
Next: Next, you will navigate parents and children without assuming an object always exists.
Studio Companion
Not connected
Connect once. Compatible challenges will prepare automatically as you reach them.