How to change the player's hair?
So I've been trying to make a character customization GUI and I managed to figure out how to change the player's shirt, pants and skin colour, but I'm currently stuck on changing their hair. I tried doing this:
01 | local skinChange = game:GetService( "ReplicatedStorage" ):WaitForChild( "SkinChange" ) |
02 | game:GetService( "InsertService" ):LoadAsset( 16630147 ) |
04 | skinChange.OnServerEvent:Connect( function (player, skin) |
06 | elseif skin = = "hair1" then |
07 | player.Character.Humanoid:AddAccessory( 16630147 ) |
The LocalScript is fine for sure.
This script would cause this error:
15:26:53.520 - Unable to cast value to Object
15:26:53.521 - Stack Begin
15:26:53.521 - Script 'ServerScriptService.SkinChanger', Line 22
15:26:53.522 - Stack End
(Line 22 is line 7 here)
I also tried to get the hair I want for the game to the ServerStorage, but I couldn't figure out how to add items from the catalog to it. I also realized some games that have avatar customization like Robloxian High School just need the Id of the hat to work.
I hope somebody can help me.