How do I fix using backspace to drop my tool from deleting all the scripts?

Hi, I want to fix my issue of whenever I press backspace It just deletes all my scripts in it. I have tried looking for a solution but I couldn’t find one so I decided to ask for help.

I’ve tried disabling dropping and trying to make the drop key different, but it just ends up stuck on the player’s hand


Here’s what the code looks like.

local tool = script.Parent
local playerInputService = game:GetService(“UserInputService”)

local equipped = false

equipped = true
tool.Handle.PressE.Enabled = false
equipped = false
if equipped == true then
if input.keyCode == Enum.KeyCode.P then
tool.Parent = workspace
tool.Handle.PressE.Enabled = true
equipped = false

Are there any tips on how I can combat this bug?

(also sorry if I put this under the wrong category couldn’t decide if this should’ve been code review or scripting support)

Please be more clear, if the player drops the tool into the workspace then the scripts get deleted?

Yes if they drop it into the workspace the script gets deleted

Can we please have a video or screenshot?

Here it is in my hands but yet its parent is the workspace.

Thats odd, maybe try destroying or removing the tool when it is the workspace?
use the :Remove or the :Destroy async

I had to but back in the scripts.

Ok thank you i tried and it worked :+1:

If you want a script that automatically deletes it here it is:

local tool = script.Parent

if tool.Parent == workspace then