Giving items within a Model

So, I have created a spin for element GUI, and to be more specific, I have scripted the magic within the tools.

Bildschirmfoto 2020-05-03 um 05.31.10

And the spin for magic GUI works perfectly fine, but I need some kind of script that will ungroup a model when the model will appear in the player’s backpack, so the tools would be visible and ready to use.

Help appreciated, peace!

1 Like

You could loop through the contents of the Model with a “for” loop, and set each of the parts parent to the players backpack. Then delete the Model once all the parts have been extracted.

Can you give me an example?
Because I have no idea how to make it, not even with a for loop.
Peace, ty.

I am on mobile currently, so this code might not be perfect. But here is a rough example:

for num, item in pairs(Model:GetChildren()) do

item.Parent = DesiredExtractLocation

end

Model:Destroy()

1 Like

I we’re thinking of a code that will ungroup the model when it’ll be found in a players inventory, this would’ve been an easier way, sadly I don’t know how to make it.

Unfortunately ungrouping a Model, at least to my knowledge, can not be done with as script. The closest thing would be to do as I suggested, and change the parent of all the objects inside the Model and then :Destroy() it after. It would be equivalent to ungrouping the model. Here is a function that could do it for you:

function Ungroup(Model)

for num, item in pairs(Model:GetChildren()) do

item.Parent = Model.Parent

end

Model:Destroy()

end

You would use this like this:

Ungroup(Model)