I'm trying to make a script that moves all of the children of the folder
script.Character
into
newPlayer.Character
(which is the player character). The code I have right now does not do anything. How would I move all children on my folder into the character?
game.Players.PlayerAdded:connect( function(newPlayer) newPlayer:WaitForChild("PlayerGui") local PlayerGuiFolder = script.Player.PlayerGui:clone() PlayerGuiFolder.Parent = newPlayer.PlayerGui local character = script.Character:GetChildren() character.Parent = newPlayer.Character end
Well, you have the right idea, just using the wrong function. There are a few ways to achieve your goal, but I prefer to use a generic loop, which is commonly known as the for loop that includes pairs. Script:
game.Players.PlayerAdded:connect(function(newPlayer) newPlayer:WaitForChild("PlayerGui") local PlayerGuiFolder = script.Player.PlayerGui:clone() PlayerGuiFolder.Parent = newPlayer.PlayerGui for i,v in pairs(script.Character:GetChildren()) do v.Parent = newPlayer.Character end end)