Advertisement
CloneTrooper1019

Roblox - WaitForChild Hierarchy

Feb 15th, 2014
460
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.53 KB | None | 0 0
  1. function WaitForChildHierarchy(start,...)
  2.     if not start:IsA("Instance") then return end
  3.     local currentObj = start
  4.     for _,v in pairs{...} do
  5.         if type(v) == "string" then
  6.             currentObj = currentObj:WaitForChild(v)
  7.         end
  8.     end
  9.     return currentObj
  10. end
  11.  
  12. -- In case you have to do something stupid like for example:
  13. local hat = workspace:WaitForChild("GameModel"):WaitForChild("Storage"):WaitForChid("Hats"):WaitForChild("Hat1")
  14.  
  15. -- You can just do this
  16. local hat = WaitForChildHierarchy(workspace,"GameModel","Storage","Hats","Hat1")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement