Advertisement
Guest User

Untitled

a guest
Jan 19th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. local function deepFindByName(nameOfPart)
  2. local function getDescendants(t)
  3. local x,t={},t:GetChildren()
  4. for i=1,#t do
  5. x[#x+1]=t[i]
  6. local g=getDescendants(t[i])
  7. for i=1,#g do
  8. x[#x+1]=g[i]
  9. end
  10. end
  11. return x
  12. end
  13. local t=getDescendants(workspace)
  14. for i=1,#t do
  15. if t[i].Name==nameOfPart then
  16. return t[i],t[i].Parent:IsA("Model")
  17. end
  18. end
  19. end
  20.  
  21. print(deepFindByName("Part"))
  22. --prints the part it finds AND a boolean if the parent is a model
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement