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

I don't know any possible way to ungroup this model. Help please?

Asked by 10 years ago

Okay , so I'm making minigames, and all the tools for one minigames are in one model, but I have no clue how to ungroup the model when I put it in the player's inventory. I can't just keep the tools in the model because they don't show unless they're ungrouped.

Here's the script:

local Players=Game.Players
local ServerStorage=Game.ServerStorage
local ServerScriptService=Game.ServerScriptService

connections={}

function gameOver()
    for i=1,#connections do
        connections[i]:disconnect()
    end
    connections={}
end

function spawnCharacter(plr)
    spawnpoints=map.SpawnPoints:GetChildren()
    plr.Character:MoveTo(spawnpoints[math.random(1,#spawnpoints)].Position)
    stats=plr.leaderstats
    local brickBattleTools=ServerScriptStorage.Tools["BrickBattle Bloodshed"] --This is the model with the tools, but I don't know how to ungroup it.
    brickBattleTools.Parent=plr.Backpack
    if not stats:FindFirstChild("Kills") then
        kills=Instance.new("IntValue",stats)
        kills.Name="Kills"
        kills.Value=0
    end
end

ServerStorage["Default Minigame StartEvent"].Event:connect(function()
    plrs=Players:GetChildren()
    map=Workspace

    lastSpawnPointUsed=0

    for i,plr in pairs(plrs) do
        if plr.Character~=nil then
            lastSpawnPointUsed=lastSpawnPointUsed+1
            spawnCharacter(plr)
        end
        connections[#connections+1]=plr.CharacterAdded:connect(function(chr)
            spawnCharacter(Players:GetPlayerFromCharacter(chr))
        end)
    end
    wait(20)
    ServerStorage.MinigameOver:Fire(plrs,50)
end)

I'm not 100% sure about this, but I do think I can use :GetChildren() to make this work somehow, but again, not 100% sure.

The script isn't completely finished though.

1 answer

Log in to vote
4
Answered by 10 years ago

You could use a script like this:

for i, v in pairs(brickBattleTools:GetChildren()) do
    if v.ClassName == "Tool" then
    v:Clone().Parent = plr.Backpack
    end
end)

This would go through the model and if the ClassName of the stuff inside the model is equal to a tool then clone it and put it in the players backpack.

0
Oh thanks! Ugh_Emily 25 — 10y
Ad

Answer this question