✓ Accepted answer
On line 4, you're checking if BodyColors is in the part, not the character.
Easy fix. I would actually just get rid of checking for BodyColors all together, but it's up to you.
game.Players.PlayerAdded:connect(function(Player)
Player.CharacterAdded:connect(function(Char)
if Char:FindFirstChild('Body Colors') then
for i,v in pairs(Char:GetChildren()) do
if v.ClassName == 'Part' then
v.BrickColor = BrickColor.new('Sea green')
end
end
end
end)
end)
If you did want to check for body colors, you would use FindFirstChild, which I did on line 3.
You have to destroy BodyColors before changing colors.
If you don't the character will just change back when BodyColors loads. Use WaitForChild to wait for BodyColors, and destroy it.
game.Players.PlayerAdded:connect(function(Player)
Player.CharacterAdded:connect(function(Char)
Char:WaitForChild('Body Colors'):Destroy()
for i,v in pairs(Char:GetChildren()) do
if v:IsA("Part") then
v.BrickColor = BrickColor.new('Sea green')
end
end
end)
end)
I also changed the .ClassName to use the IsA function because it seems simpler and will do ultimately the same thing.
Good Luck!
If I helped, please don't forget to accept my answer.
4 comments
Error: Body Colors is not a valid member of Model
Made me green for 1 second, then turned back normal,
read the whole article?
We were talking in the chat. I made a few errors in my script so his comments are called for. It's working now though