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

Accessory Being Worn By A Character When It's Not Worn By Anything?

Asked by 1 year ago

This error/warning just doesn't make sense

AddAcessory failed: Accessory is already being worn by another character.

No. The accessory is freshly cloned and not being worn by anything.

game.Players.PlayerAdded:Connect(function(plr)
    local clone = game.ReplicatedStorage.Backpack:Clone()
    local char = plr.CharacterAdded:Wait()
    clone.Parent = char
    local hum = char:WaitForChild("Humanoid")
    hum:AddAccessory(clone)
    end)

2 answers

Log in to vote
0
Answered by
NykoVania 231 Moderation Voter
1 year ago

Try this.

Code:

game.Players.PlayerAdded:connect(function(plr)
    plr.CharacterAppearanceLoaded:connect(function(char)
        local hum = char:WaitForChild("Humanoid")
        hum:AddAccessory(game.ReplicatedStorage.Backpack) 
        hum.Died:connect(function()
            char:FindFirstChild("Backpack").Parent = game.ReplicatedStorage
        end)
    end)
end)
Ad
Log in to vote
0
Answered by 1 year ago

Setting the parent of the accessory automatically adds it to the humanoid technically. So, when you call :AddAccessory, it has already been put inside the player's character model. Instead, do this:

game.Players.PlayerAdded:Connect(function(plr)
    local clone = game.ReplicatedStorage.Backpack:Clone()
    local char = plr.CharacterAdded:Wait()
    local hum = char:WaitForChild("Humanoid")
    hum:AddAccessory(clone)
end)

the only thing changed is the .Parent line is removed.

Answer this question