← Back to course
medium ✦ 75 Studs

Finding Other Objects

Reach across the Explorer with FindFirstChild and WaitForChild to grab any object by name.

So far your scripts have mostly bossed around their own part with script.Parent. But a real game is parts talking to each other: a lever opens a door, a button across the room lights up a sign. To do that, your script has to reach out and find an object somewhere else in the Explorer. That is what this lesson is about.

The Explorer is a tree. At the top sits game, and underneath it are the big containers, the services: Workspace (everything you can see in the 3D world), Players, StarterGui, and more. You walk down that tree with dot notation, exactly like reaching into a dictionary:

local door = workspace.Door
local players = game.Players

That works, but it has a trap. If Door is not loaded yet, or you spelled it wrong, workspace.Door throws an error and your whole script stops. So Roblox gives you two safer ways to reach for a child.

FindFirstChild looks for a child by name and hands you nil if it is not there, instead of crashing. That lets you check before you act:

local door = workspace:FindFirstChild("Door")
if door then
  door.Color = Color3.fromRGB(0, 255, 0)
else
  print("No Door found, check the name")
end

WaitForChild is the one you will use most. It pauses your script until the object shows up, then hands it to you. This matters because the game world loads in pieces, and a Script can run before the part it wants has fully loaded. WaitForChild quietly waits out that race:

local door = workspace:WaitForChild("Door")
door.CanCollide = false -- now players can walk through it

Notice the colon : in workspace:WaitForChild(...) instead of a dot. The colon is how you call a function that belongs to an object, you have seen it with :Connect. The dot reaches a property or child, the colon calls a method. Mixing those two up is the number one beginner trip, so when something “does not exist,” check your dots and colons first.

One more handy tool: names can repeat, so game.Players is how you reach every player, and inside a script you will often grab a specific player or their character and then WaitForChild your way down to the exact part you need.

Now make it yours: build a tiny lever-and-door setup, then try chaining the search, like grabbing a folder first and then a part inside it, so you get comfortable navigating deeper into the Explorer tree. That skill is the backbone of every tycoon you are about to build.

Build this in Roblox Studio, then check off each step: