Can i find a part ANYWHERE in the workspace?

What i mean is letrs say i wanna find a part called “The Part”
I CAN do “Workspace:GetChildren” or whatever in a for loop, but thats only gonna look for the part in just the workspace alone
But i want to find it even if its 10 folders deep inside workspace
basically maybe “The Part” is in a folder, that is in a folder, that is in a folder, ect
I want to still be able to access that part, even when its location moves.
IF you understnad what i mean, Thanks for the help

Then you would use :GetDescendants()

But, it will loop through every single thing in your game if it is started from the workspace.

You might want to learn about CollectionService:

Or maybe just use ObjectValues instead of paths:

1 Like

GetDecendants() Worked!
I never knew exactly what it did, just thought it was the same as getchildren()
Also my example isint what im actually doing, im actually looking in a folder, so its not laggy at all!

Bruh,u dont need a loop

U can just do this

If game.Workspace:FindFirstChild(-- part name) then

End

Unless it is a cloned model-- then use the loop.(no choice)

Might be good to add that you’d have to pass true as a second argument in :FindFirstChild() as without it it won’t check deeper than just the children of the target.

Passing the second argument “true” will perform the search recursively

1 Like

If you have streaming on, the part will not load unless you’re inside streaming range. Other than that you should be able to access every part in the workspace.

They said they wanted to find it even if it wasn’t parented to workspace by “ten folders parented to each other inside of workspace” so no. They’d have to use a loop to find their part…

(NVM you were right. I’ll just edit my post ig)

So if you did game.Workspace:FindFirstCHild(partName, true) it would check through all descendants for the part???

local part = workspace:FindFirstChild(partName,true)
2 Likes

Correct.

The arguments for FindFirstChild are as follows:
name? : string
recursive? : boolean

Recursive just means that it looks through all children recursively (looks within the children of the current child, etc etc)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.