Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Help with cloning multiple things together?

Here is the code:

player = script.Parent.Parent 
player.CanLoadCharacterAppearance = false 
character = player.Character
character.Head.BrickColor = BrickColor.new("Bright yellow")
character.Torso.BrickColor = BrickColor.new("Bright yellow")
character["Left Arm"].BrickColor = BrickColor.new("Bright yellow")
character["Right Arm"].BrickColor = BrickColor.new("Bright yellow")
character["Left Leg"].BrickColor = BrickColor.new("Bright yellow")
character["Right Leg"].BrickColor = BrickColor.new("Bright yellow")


game.ServerStorage.farmer:GetChildren():Clone().Parent = character


It keeps erring, saying that Clone is a nil value, but I clearly assigned the parent of character to the clone. Anyways, it would be great to help with this and also is there an easier way to color the character's body colors without doing each and every part?

Thanks in advanced

1 answer

The problem is that GetChildren() returns a table containing the children, but Clone() can only be called on an individual child. You need to loop through the table and call Clone() on each child, like this:

for i, v in ipairs(game.ServerStorage.farmer:GetChildren()) do
	v:Clone().Parent = character
end

3 comments

0

How is GetChildren() useful?

0

Also, what does i, v in pairs do/mean . Could i use different letters?

0

Yes

This discussion is preserved as it was. New answers, comments, and votes are closed.