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

How could I do this? Trying to clone BoolValues into player.

It's a LocalScript.

So, basically, I'm trying to have a system whereby I can put some BoolValues inside the LocalScript as Children, and when a player joins, those BoolValues get copied into the player model.

However, it does nothing.

game.Players.PlayerAdded:connect(function(player)
	local values = script:GetChildren()
	local valueclones = values:Clone()
		valueclones.Parent = player.Character

end)

1 comment

0

try putting it into game.Players:WaitForChild(player.Name) or game.Workspace:WaitForChild(player.Name)

1 answer

The issue encountered: You're trying to Clone() a table and not the elements inside that table. That simply doesn't work

Use a for loop

game.Players.PlayerAdded:connect(plr)
	repeat wait() until plr.Character
	for i, v in pairs(script:GetChildren()) do
		v:Clone().Parent=Character
	end
end)

That for loop will run as many times as there are objects and it will clone each one into the player's character.

I stands for index and v stands for value. We are cloning v(being the object in the table into the character)

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