Cant change player color

So, i made a code this summer and it did not work. I am very curious why, because i have literally no idea what was wrong there. I have got the entire script here, but i already rewritten the script in game and it works but i am probably not going to be able to give more context, hovewer ask if necessary maybe i will find something. The problem is inside this code, because i only changed this script and it started working. It didnt even give errors, just didnt work.

local colorh = game.ReplicatedStorage.ColorHair.Value
local colors = game.ReplicatedStorage.ColorShirt.Value
local colorp = game.ReplicatedStorage.ColorPants.Value


game.ReplicatedStorage.Events.SetColors.OnServerEvent:Connect(function(plr)
   local hair = plr.Character.Head.Hair.Hair
   local pants = plr.Character.Pants
   local shirt = plr.Character.Shirt

   if colorh == 1  then
   	hair.BrickColor = BrickColor.new("Institutional white")
   elseif colorh == 2 then
   	hair.BrickColor = BrickColor.new("Really black")
   elseif colorh == 3 then
   	hair.BrickColor = BrickColor.new("Sand green")
   elseif colorh == 4 then
   	hair.BrickColor = BrickColor.new("New Yeller")
   elseif colorh == 5 then
   	hair.BrickColor = BrickColor.new("Persimmon")
   elseif colorh == 6 then
   	hair.BrickColor = BrickColor.new("Electric blue")
   elseif colorh == 7 then
   	hair.BrickColor = BrickColor.new("Bright green")
   elseif colorh == 8 then
   	hair.BrickColor = BrickColor.new("Alder")
   elseif colorh == 9 then
   	hair.BrickColor = BrickColor.new("Flame yellowish orange")
   elseif colorh == 10 then
   	hair.BrickColor = BrickColor.new("Teal")
   end
   
   if colorp == 1  then
   	pants.Color3 = Color3.fromRGB(255,255,255)
   elseif colorp == 2 then
   	pants.Color3 = Color3.fromRGB(0,0,0)
   elseif colorp == 3 then
   	pants.Color3 = Color3.fromRGB(125,125,125)
   elseif colorp == 4 then
   	pants.Color3 = Color3.fromRGB(255,255,0)
   elseif colorp == 5 then
   	pants.Color3 = Color3.fromRGB(255,80,80)
   elseif colorp == 6 then
   	pants.Color3 = Color3.fromRGB(50,120,255)
   elseif colorp == 7 then
   	pants.Color3 = Color3.fromRGB(80,200,100)
   elseif colorp == 8 then
   	pants.Color3 = Color3.fromRGB(180,40,255)
   elseif colorp == 9 then
   	pants.Color3 = Color3.fromRGB(250,160,50)
   elseif colorp == 10 then
   	pants.Color3 = Color3.fromRGB(90,255,200)
   end
   
   if colors == 1  then
   	shirt.Color3 = Color3.fromRGB(255,255,255)
   elseif colors == 2 then
   	shirt.Color3 = Color3.fromRGB(0,0,0)
   elseif colors == 3 then
   	shirt.Color3 = Color3.fromRGB(125,125,125)
   elseif colors == 4 then
   	shirt.Color3 = Color3.fromRGB(255,255,0)
   elseif colors == 5 then
   	shirt.Color3 = Color3.fromRGB(255,80,80)
   elseif colors == 6 then
   	shirt.Color3 = Color3.fromRGB(50,120,255)
   elseif colors == 7 then
   	shirt.Color3 = Color3.fromRGB(80,200,100)
   elseif colors == 8 then
   	shirt.Color3 = Color3.fromRGB(180,40,255)
   elseif colors == 9 then
   	shirt.Color3 = Color3.fromRGB(250,160,50)
   elseif colors == 10 then
   	shirt.Color3 = Color3.fromRGB(90,255,200)
   end
end)
2 Likes

I think the hair is covered by texture so you can’t change the color via BasePart.BrickColor

I removed the texture, so brickcolor can be applied. In the working code it’s also with brickcolor so it cant be it.

instead of putting the value directly in a variable, put the instance in a variable and then get the value, instead of:

local colorh = game.ReplicatedStorage.ColorHair.Value
if colorh == 1  then
end

instead do(pseudo code) inside the onserverevent:

local colorh = game.ReplicatedStorage.ColorHair
if colorh and colors and colorp then
	if colorh.Value == 1  then
	end
end

hopefully this helps

Is ColourHair definitely a NumberValue?
Does the event definitely get recieved?

Yeah that is the part where i cant give more context, sorry. It could be, but as I dont have the code anymore i cannot confirm. thanks anyways :+1:

I think this one might really be it, I cannot confirm as I dont have the code anymore but it broke similarily with other codes if I remember well. Thanks :+1: