Using an APY helping script and it doesn't drop a weapon but destroys it! How can I prevent weapon from destroying while changing a weapon in the same socket?
Did you use
EQUIPMENT:Unequip()
Have you checked Dropping weapon script - Scripting Help - Core Creator Forums (coregames.com) ?
local EQUIPMENT = script.parent
local TRIGGER = script.parent:FindDescendantByType("Trigger")
function Drop(equipment)
equipment:Unequip()
-- The pickup trigger needs to be re-enabled (if there is one)
local pickupTrigger = equipment:FindDescendantByType("Trigger")
if pickupTrigger then
pickupTrigger.collision = Collision.FORCE_ON
end
end
function OnEquipped(equipment, player)
for _, e in ipairs(player:GetEquipment()) do
if e ~= equipment and e.socket == equipment.socket then
Drop(e)
end
end
end
function OnInteracted(trigger, player)
TRIGGER.collision = Collision.FORCE_OFF
EQUIPMENT:Equip(player)
end
EQUIPMENT.equippedEvent:Connect(OnEquipped)
TRIGGER.interactedEvent:Connect(OnInteracted)
Error - can't access destroyed object? How can I prevent weapons from destroying?