I'm trying to change the hair color of the character in an easy way using "WaitForChild" I've tried "FindFirstChild" too, but it only works if I put the specific name of that, butit can be any one depending on the choice of the player
(When the player appears, a folder is created on the "head" of the character, depending on the player's choice one of the hairs will go there, I named Hair1, Hair2 and so on, and I try to change the color of that inside the folder)
what's wrong and how do i fix it?
I am a total beginner in scripting
game.ReplicatedStorage.Events.HairColorEvent1.OnServerEvent:Connect(function(plr) local color = BrickColor.new("Baby blue") local char = plr.Character char.Head.Hair:WaitForChild().BrickColor = color ?------error "argument 1 missing or nil" end)
You are using WaitForChild the wrong way. You don't put the child and then :WaitForChild()
, you put it inside. Like this:
char.Head:WaitForChild("Hair").BrickColor = color