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

having trouble with adding acessory to player when they click a gui what's the problem?

Asked by 1 year ago
Edited 1 year ago

the accessory spawns in but it falls through the baseplate and does not attach to the head.

local player = game.Players.LocalPlayer.Character
local humanoid = player:WaitForChild("Humanoid")
script.Parent.MouseButton1Click:Connect(function()
        local cmesh = Instance.new("CharacterMesh", player)
        cmesh.MeshId = 0
        cmesh.BodyPart = "Torso"
        player.Shirt.ShirtTemplate = "rbxassetid://0"
        player.Pants.PantsTemplate = "rbxassetid://0"
    for i, v in pairs(player:GetDescendants()) do
        if v:IsA("Accessory") then
            v:Destroy()
        end
    end
    local hair = Instance.new("Accessory")
    hair.Name = "Hair"
    local handle = Instance.new("Part")
    handle.Name = "Handle"
    handle.Size = Vector3.new(1, 1, 1)
    handle.Parent = hair
    local HairAttachment = Instance.new("Attachment")
    HairAttachment.Name = "HairAttachment"
    HairAttachment.Position = Vector3.new(0.054, 7.18, -0.096)
    HairAttachment.Parent = handle
    local mesh = Instance.new("SpecialMesh")
    mesh.Name = "Mesh"
    mesh.Scale = Vector3.new(1, 1, 1)
    mesh.MeshId = "rbxassetid://0"
    mesh.TextureId = "http://www.roblox.com/asset/?id=0"
    mesh.Parent = handle
    humanoid:AddAccessory(hair)
end)

Answer this question