How do I go about changing character parts colors?

So basically I wanted to make an attempt to change the character parts colors of the players who join my game by using this script:

Script
local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(plrchar)
		for i, v in next, plrchar:GetChildren() do
			if v:IsA("Part") then
				v.Color = Color3.fromRGB(0,0,0)
				print("done")
			end
		end
	end)
end)

But the problem is that the parts don’t turn into the new color that the script is giving them and the only thing that I have noticed is that it only prints 2 times and then stop like shown in the image below:

CharacterAddedEvent

But what it’s actually supposed to do is that it should print “done” depending on the number of parts that your character has but I have no idea why it does that instead, does anyone have any solutions or does anyone know what’s the best way to change the character parts colors?

4 Likes

Try for i, v in pairs(plrchar:GetChildren()) do

If that doesn’t work look at this: BasePart | Documentation - Roblox Creator Hub

That is not related to this problem, my method of doing that will still work with no problems.

Ok try the link then, I think it should help

I think your problem is that most of a players body parts are mesh parts so try or v:IsA("MeshPart)

But i don’t know

edit: It printed 16 times.

1 Like

That could be the problem…

That still doesn’t work, I’m still looking for solutions.

I thinks it because of the players character loading in too fast, I put a wait and it worked, but for only one arm…

That’s weird, it would be very nice if someone explains to us why that happens.

So in the script i deleted the body colors of the players character and it works better, but the arms:

In R16, the character is a MeshPart classname, not a “Part” only

This worked:
I changed the players body colors properties:

Here is the script(Im sure there is a more efficient way to do it):

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(plrchar)
		plrchar["Body Colors"].HeadColor3 = Color3.fromRGB(0,0,0)
		plrchar["Body Colors"].LeftArmColor3 = Color3.fromRGB(0,0,0)
		plrchar["Body Colors"].RightArmColor3 = Color3.fromRGB(0,0,0)
		plrchar["Body Colors"].LeftLegColor3 = Color3.fromRGB(0,0,0)
		plrchar["Body Colors"].RightLegColor3 = Color3.fromRGB(0,0,0)
		plrchar["Body Colors"].TorsoColor3 = Color3.fromRGB(0,0,0)
	end)
end)


5 Likes

It doesn’t work even if I changed the check on v to MeshPart instead of Part.

Thank you so much your solution works, I didn’t expect it to work like that.

1 Like

Change v to be either v is a Part or v is a MeshPart and wait until the player character has fully loaded into the game.

The script is attempting to change colors of the parts before the players character model has fully loaded.

OR you can do it like solution did it

1 Like

Easy way that I use:

local bodyColors = character:FindFirstChild("Body Colors")
if bodyColors then
	bodyColors.HeadColor = color
	bodyColors.LeftArmColor = color
	bodyColors.LeftLegColor = color
	bodyColors.RightArmColor = color
	bodyColors.RightLegColor = color
	bodyColors.TorsoColor = color
end
1 Like

thank you, this was amazing and worked for my game.