How to find a child with a specific name

So I want to find a specific part with a specific name and idk know how to look inside a model and find a specific part with a different name then the other parts using a script.

2 Likes

You use FindFirstChild.

Take a look at this link:

Try using this code (example) :

local MyModel = game.Workspace.MyModel
local MySpecificPart = MyModel:FindFirstChild("MySpecificPart")
3 Likes

If you know it exists, you can also do this:

local MyModel = game.Workspace.MyModel
local MySpecificPart = MyModel["MySpecificPart"]

Sometimes I find this to be easier to read–however, if the child doesn’t exist then it will error.

1 Like

Wouldn’t we also be able to do this as well?

If we know it will exist or do know it exists

local MyModel = game.Workspace.MyModel
local MySpecificPart = MyModel:WaitForChild("MySpecificPart")
1 Like