Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function deepFindByName(nameOfPart)
- local function getDescendants(t)
- local x,t={},t:GetChildren()
- for i=1,#t do
- x[#x+1]=t[i]
- local g=getDescendants(t[i])
- for i=1,#g do
- x[#x+1]=g[i]
- end
- end
- return x
- end
- local t=getDescendants(workspace)
- for i=1,#t do
- if t[i].Name==nameOfPart then
- return t[i],t[i].Parent:IsA("Model")
- end
- end
- end
- print(deepFindByName("Part"))
- --prints the part it finds AND a boolean if the parent is a model
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement