How to set Body Colors's colors with a script?

hi, I was working at a sistem when a player leaves the game and he is in a round a npc with his look win clone in his position, the problem is i can’t change Body Colors’s color. My Script:


	for name,Id in pairs(InfoBodyColors) do
		local NewName = string.sub(name,1,string.len(name) - 2)
		BodyColors[NewName] = BrickColor.new(Id)
	end

2 Likes
bodyColors = {'HeadColor', 'LeftArmColor', 'LeftLegColor', 'RightArmColor', `'RightLegColor', 'TorsoColor'}`


game:GetService('Players').PlayerRemoving:connect(function(player)
    player.CharacterAdded:connect(function(char)
        for _,color in pairs(bodyColors) do
            char["Body Colors"][color] = BrickColor.new("Institutional white")
        end
    end)
end)

This code might help you, you may need to make some changes also. I haven’t tested the code but it should work

@briana_superstar

this thing is the same thing, but still don’t work, this gets will get all the body parts and change they colors:


for name,Id in pairs(InfoBodyColors) do
		local NewName = string.sub(name,1,string.len(name) - 2)
		BodyColors[NewName] = BrickColor.new(Id)
	end

edit: ur code don’t work

I’ve never seen a PlayerLeaving event on Players? I dont actually know if PlayerLeaving exists cause I usually use PlayerRemoving.

there don’t exists PlayerLeaving

As for this problem, how about clone the player characters BodyColors and paste them onto the NPC before said player leaves? I use this method when turning players into certain characters and I wonder if it will work in this situation.

2 Likes

My bad, I just wrote it here and I wrote the wrong event :sweat_smile: