I want to get all services and objects in my game, I thought about using GetChildren() over and over and over, but I realized that if someone else used this, they may have more models in workspace then I do, so then this method would not work, so how could I do this?
COMMUNITY QUESTION
How would I get all services and instances/objects in my game?
1 answer
local instanceTable = {}
function getInstances(Instance)
Instance = Instance or Game
for i,v in pairs(Instance:GetChildren()) do
table.insert(instanceTable, v)
getInstances(v)
end
end
getInstances() --instanceTable is now filled with all in-game instances.
This discussion is preserved as it was. New answers, comments, and votes are closed.
