So I'm making an avatar customiser where players can put on accessories that I made. But when the accessory is equipped it doesnt stay on the players head and instead stays in the position in the workspace where i made it. I dont know if this has anything to do with the script. Here is the code (Client sided):
local equipped = script.Parent:GetAttribute("Equipped")
local plr = script.Parent.Parent.Parent.Parent.Parent.Parent
local character = plr.Character
script.Parent.MouseButton1Click:Connect(function()
if equipped == true then
for i,v in pairs(character:GetChildren())do
if v:IsA("Accessory")then
if v.Name == script.Parent.Name then
v.Parent = script.Parent.Parent.Parent.Parent.Parent.Parent.Accessories
end
end
end
if character:FindFirstChildWhichIsA("Accessory") then
else
for i,v in pairs(script.Parent.Parent.Parent.PlayerAccessories:GetChildren()) do
v.Parent = character
end
end
equipped = false
script.Parent.Equipped.Visible= false
else
local accessory = game.Players.LocalPlayer.Accessories:FindFirstChild(script.Parent.Name)
for i, a in pairs(character:GetChildren()) do
if a:IsA("Accessory") then
if a:GetAttribute("Custom") == nil then
a.Parent = script.Parent.Parent.Parent.PlayerAccessories
end
end
end
character.Humanoid:AddAccessory(accessory)
equipped = true
script.Parent.Equipped.Visible = true
end
end)

1 comment
If you're looking to attach accessories to a player, make sure you have an attachment in the accessory with the same name as a player attachment.