Humanoid:AddAccessory() not working afte player dies

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to add an accessory to the player after they die
  2. What is the issue? Include screenshots / videos if possible!
    The accessory wasn’t added to the player and it doesn’t give any error
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I’ve looked for solutons on The Devforum but no one seems to have to same problem as I do

Here’s the code I used

game.Players.PlayerAdded:Connect(function(player)
local char = player.Character or player.CharacterAdded:Wait()
local humanoid = char:WaitForChild(“Humanoid”)
local accessory = game.ReplicatedStorage.Accessory:Clone()
wait(1)
humanoid.Health = 0
wait(7)
humanoid:AddAccessory(accessory)
end)

It could be because after the character dies, the humanoid is destroyed and replaced, if you tried

game.Players.PlayerAdded:Connect(function(player)
local char = player.Character or player.CharacterAdded:Wait()
local humanoid = char:WaitForChild(“Humanoid”)
local accessory = game.ReplicatedStorage.Accessory:Clone()
wait(1)
humanoid.Health = 0
wait(7)
char = player.Character or player.CharacterAdded:Wait()
humanoid:AddAccessory(accessory)
end)

It may be different because now you’re getting the humanoid after they die.

3 Likes

There’s this beautiful event called player.CharacterAdded. Just connect a function.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.