How do you change the color and material of accesory hair?

I’ve seen in games like no big deal that hair can be changed into a certain color and removed of texture.

Here is a example, I’ve done this by turning the hair accessories’ handle into a meshpart and copying the mesh id that was inside of the original handle, into the meshpart which also had the properties of changing color and material but still having the mesh. After that, I used moon animator to weld the meshpart to the head because it hadnt actually stuck on to it. I don’t know how I would go about this when coding it ingame so whenever someone joined they would get sand materialed hair

1 Like

You can edit properties or add into this:

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local function onPlayerAdded(player)
	local character = player.Character or player.CharacterAdded:Wait()
	local hairAccessory = ReplicatedStorage:WaitForChild("SandHairAccessory"):Clone()
	hairAccessory.Parent = character
	hairAccessory.Handle.MeshId = "rbxassetid://YourMeshIdHere"
	hairAccessory.Handle.Material = Enum.Material.SmoothPlastic
	hairAccessory.Handle.Color = Color3.fromRGB(194, 178, 128)
	hairAccessory.Handle.Weld:Destroy()
	local weld = Instance.new("Weld")
	weld.Part0 = character.Head
	weld.Part1 = hairAccessory.Handle
	weld.C0 = CFrame.new(0, 0, 0)
	weld.Parent = hairAccessory.Handle
end

Players.PlayerAdded:Connect(onPlayerAdded)

That’s the thing, the handle doesn’t have a meshid or mesh texture, instead it has a special texture inside of it that can’t be modified of material and color. That’s why I wanna use meshparts somehow because they let you set the material and color of a mesh even if you dont have a texture.

Now I see this one would use a meshpart and can be “edit-able”

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local function onPlayerAdded(player)
	local character = player.Character or player.CharacterAdded:Wait()
	
	-- Create a new MeshPart for the hair accessory
	local hairAccessory = Instance.new("MeshPart")
	hairAccessory.MeshId = "rbxassetid://YourMeshIdHere" -- Set your MeshId here
	hairAccessory.Material = Enum.Material.SmoothPlastic
	hairAccessory.Color = Color3.fromRGB(194, 178, 128)
	hairAccessory.Size = Vector3.new(1, 1, 1) -- Adjust the size as needed
	hairAccessory.Anchored = false
	hairAccessory.CanCollide = false
	
	-- Position it correctly (you may need to adjust the CFrame)
	hairAccessory.CFrame = character.Head.CFrame * CFrame.new(0, 0.5, 0) -- Adjust the offset as needed
	
	-- Weld it to the character's head
	local weld = Instance.new("Weld")
	weld.Part0 = character.Head
	weld.Part1 = hairAccessory
	weld.C0 = CFrame.new(0, 0, 0) -- Adjust the weld position if necessary
	weld.Parent = hairAccessory
	
	hairAccessory.Parent = character -- Parent the MeshPart to the character
end

Players.PlayerAdded:Connect(onPlayerAdded)