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:

local skinChange = game:GetService("ReplicatedStorage"):WaitForChild("SkinChange") -- "SkinChange" is a RemoteEvent
game:GetService("InsertService"):LoadAsset(16630147)

skinChange.OnServerEvent:Connect(function(player, skin)
	-- Code for changing the shirt and hair
	elseif skin == "hair1" then
		player.Character.Humanoid:AddAccessory(16630147)
	-- Code for more options to the hair (not working) and skin colour
	end
end)

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.

3 comments

0

Is player.Character.Humanoid:AddAccessory(Accessory item, not id)

0

So, like an object in Workspace or ServerStorage?

0

You can put in Workspace,ServerStorage or ReplicatedStorage