[Solved] Droping items on death

i am working a custom inventory and i have been facing a problem dropping items. I have followed this Redirecting... but it keeps giving an error that the equipment have been destoryd and can not be modified.

Any one can help ?

Solved :slight_smile:

But how did you solve it?

For anyone who wants to drop items on death the script below should suffice, please notify me if you receive any errors.

(Assuming this script is networked and is the child of a networked equipment object)

-- Get the "equipment" object 
local EQUIPMENT = script.parent
-- Create an empty object that will reference the "diedEvent" listener
local playerDeathListener = nil

   -- Callback that runs when the owner of the equipment dies
function OnPlayerDeath(player,  damage)
    -- It's a good habit to disconnect callbacks when you are done with them
    playerDeathListener:Disconnect()
    UnequipParent(player:GetWorldPosition())
end

-- Unequips the parent from the player and sets the equipment's position
-- to the player's position
function UnequipParent(position)
    EQUIPMENT:Unequip()
    EQUIPMENT:SetWorldPosition(position)
end

-- Adds a listener for the "diedEvent"
function OnEquip(_, player)
   -- Setup a listeneder so that the "OnPlayerDeath" callback can be disconnected later
    playerDeathListener  = player.diedEvent:Connect(OnPlayerDeath)
end