How can I prevent core weapon from destroying if I have no access to the method destroy() when reequipping?
Within the equipment object there is are multiple scripts. Within one of those scripts, the "Destroy()" method is called, replacing the "Destroy()" method with "Unequip()" will prevent the equipment from being destroyed.
There are no other scripts in equipment object, only my. So I can"t find this awful destroy() method, and replace it with unequip() method.
Try placing this script within the equipment object. Both this script and the equipment need to be networked and the script requires one core object reference custom property called "Equipment" that refers to the equipment object.
--Core Object Reference to the equipment object that will be Unequippied upon the owner's death local EQUIPMENT = script:GetCustomProperty("Equipment"):WaitForObject() --Event listener to the player's "diedEvent" local deathEventListener = nil ---Function called when the player dies function OnDeath(player) --Unequip the EQUIPMENT object EQUIPMENT:Unequip() --Disconnec the "deathEventListener", this will prevent it from being called multiple times deathEventListener:Disconnect() end --Function Called when the player EQUIPMENT object is equipped function OnEquip(equipment, player) --Bind the "OnDeath" function to the player's "diedEvent" and store the resultant event listener in the "deathEventListener" variables deathEventListener = player.diedEvent:Connect(OnDeath) end