Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Im trying to use code to make it so it creates a hair mesh for the player?

This is what my script does: It deletes the player's current clothing and hair mesh etc. Then it adds the clothing and hair that I want. The clothing works fine. But when I try to put in a hair mesh id, it doesn't work. I looked at some other scripts, and they used ids. I put the id into the roblox catalog thing and it took me to a thing called " RenderMesh " I used the rendermesh id instead, and it worked. I wanted to know how I could find this Rendermesh for the hair im using.

1 answer

✓ Accepted answer

If your hair is from the catalog, you can easily use InsertService

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

function playerAdded(player)
	player.CharacterAdded:connect(function(character)
		removeAccessories(character)
		changeHair(character, 16630147) -- paste hair id, has to be created by you or ROBLOX or it wont work
	end)
end

function removeAccessories(character)
	for _, v in pairs(character:GetChildren()) do 
		if v:IsA("Accessory") then 
			v:Destroy()
		end
	end
end

function changeHair(character, hairid)
	local ContainerModel = InsertService:LoadAsset(hairid) -- when you insert something, it automatically creates a model and sets the asset's parent to the model

	for _, v in pairs(ContainerModel:GetChildren()) do 
		if v:IsA("Accessory") then 
			v.Parent = character
			ContainerModel:Destroy()
		end
	end
end

Players.PlayerAdded:connect(playerAdded)

3 comments

0

Idk if this is from the catalog because I can't find it. This is an id for one of the meshes im talking about. 250264520. I can't find it in the catalog or the library when I type it in.

0

This is the code for the texture, 75975464 and I think this is the name because I just tried it right now in the library and it worked. I wanted to know how to get these meshes also. Cuz idk how to find them.

This discussion is preserved as it was. New answers, comments, and votes are closed.