Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function GetAll(ancestor,classes)
- local allObjs = {}
- local function objPass(obj)
- for _,v in pairs(classes) do
- if (obj:IsA(v)) then
- return true
- end
- end
- return false
- end
- local function recurs(anc)
- for _,v in pairs(anc:GetChildren()) do
- if (objPass(v)) then
- table.insert(allObjs,v)
- end
- recurs(v)
- end
- end
- recurs(ancestor)
- return allObjs
- end
- -- Examples:
- local parts = GetAll(game.Workspace.Model,{"BasePart"})
- local all = GetAll(game.Workspace.Model,{"Instance"})
- local foo = GetAll(game.Workspace.Model,{"SpawnLocation","Flag","ObjectValue"})
Add Comment
Please, Sign In to add comment