Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

How to ungroup models in game?

Asked by 10 years ago
    if game.Players.NumPlayers > 1 then
        h.Text = "Deciding what map to play"
        wait(5)
        ranMap = math.random(1, #map)
        mapChosen = map[ranMap]
        h.Text = "Map Chosen: " .. mapChosen.Name
        wait(3)
        mapChosenClone = mapChosen:Clone()
        mapChosenClone.Parent = game.Workspace.MapHolder
        wait(2)

Ok, so this will pick a random map from ServerStorage. It then takes that map to MapHolder. I need an added extra. I need it to ungroup itself once in the MapHolder. Anyone help?

1 answer

Log in to vote
0
Answered by
duckwit 1404 Moderation Voter
10 years ago

"Ungrouping" is equivalent to setting the Parent property of each Child of the Model to the Model's Parent value, and then deleting the Model that contained the children.

You can write a function to do this for any object:

function Ungroup(instance)
    for _,v in pairs(instance) do
        v.Parent = instance.Parent --change Parent of each object
    end
    instance:destroy() --Delete the previous parent of the objects
end
Ad

Answer this question