Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago

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

Log in to vote
0
Answered by
hellmatic 1523 Moderation Voter
6 years ago
Edited 6 years ago

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)
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. Timbawolf1 6 — 6y
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. Timbawolf1 6 — 6y
Ad

Answer this question