How could I get all the children from inside a model together so I don't have to make a variable for each body part?
1 | local Fire = game.ServerStorage.Parts:GetChildren() -- NEED TO GET CHILDREN FROM INSIDE THIS MODEL |
2 | local firecopy = Fire:Clone() |
3 |
4 | game.Players.PlayerAdded:connect( function (player) |
5 | player.CanLoadCharacterAppearance = false |
6 | wait() |
7 | firecopy.Parent = player.Character |
8 | end ) |
The error is occurring on the first line because I can't select all the children to clone. Part is a model in server storage with package parts. Thanks.
Nice try! When you use GetChildren, it practically returns a table, filled with all of the 'children' as its values. Ex:
1 | local a = model:GetChildren() |
2 | -- Above would look like: {Apple, Button} |
To 'break' the table, you'll need to use a generic or numeric for loop, but in this case, is a generic for loop. I'll show you:
1 | local Fire = game.ServerStorage.Parts |
2 |
3 | game.Players.PlayerAdded:connect( function (player) |
4 | player.CanLoadCharacterAppearance = false |
5 | wait() |
6 | for i,v in pairs (Fire:GetChildren()) do -- iterates through all of its children |
7 | v:clone().Parent = player.Character -- clones it and puts it in the player's character |
8 | end |
9 | end ) |
01 | local Fire = game.ServerStorage.Parts:GetChildren() -- NEED TO GET CHILDREN FROM INSIDE THIS MODEL |
02 | for i = 1 , #Fire do |
03 | local firecopy = Fire [ i ] :Clone() |
04 | game.Players.PlayerAdded:connect( function (player) |
05 | player.CanLoadCharacterAppearance = false |
06 | wait() |
07 | firecopy.Parent = player.Character |
08 | end |
09 | end ) |
10 |
11 | --That's what my guess would be? |