So basically. I have a drawer that when you click the Handle, it opens and brings the key out, which I would like to have so you could press E to pick it up out of the drawer. Problem is, the scripting after I bring it out of the drawer (I think) breaks. It works normally if it isn’t in the drawer, here is the scripting:
I think you gotta add in a debounce in the second script photo. Also, you had a bunch of other formatting problems that I fixed up for you. Here is the modified code:
local tool = script.Parent
local handle = tool:WaitForChild("Handle")
local currentProx
local backpack
local isActive = false --debounce
if tool.Parent == workspace then
local proxprompt = Instance.new("ProximityPrompt")
proxprompt.Name = "Interact"
proxprompt.KeyboardKeyCode = Enum.KeyCode.E
proxprompt.ActionText = "Pick up"
proxprompt.HoldDurnation = .3
proxprompt.Parent = handle
currentProx = handle:WaitForChild("Interact")
end
currentProx.Triggered:Connect(function(Plr)
if isActive == false then
isActive = true
backpack = Plr:WaitForChild("Backpack")
tool.Parent = backpack
currentProx = nil
proxprompt:Destroy()
wait(2)
isActive = false
end)
Is the tool always a child of workspace? In your script you have it check that before you make the prompt so the problem could be that is doesn’t have the workspace as its parent.