Key in Drawer, scripting fails after opening the drawer

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:

To open the drawer:

To pick the key up: image

Please help me. Thank you.

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)
1 Like

It doesn’t appear to be working, I just replaced the script with that script. Tell me if I am doing something wrong, I don’t script.

could we get a video of what is happening?

try using this website if you do not have any recording software. Click “Get Started”, and it should ask what type of audio and video you want to record: Free Online Screen Recorder with Webcam, No Installation

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.

robloxapp-20210217-2326022.wmv (1.9 MB)

I did this with roblox, if the quality is trash I can download that screen recorder

Forgot about output

I do not know, how would you do this?

This is what was the output.

issue 2
proxprompt is underlined in red here, but snipping tool doesnt display it.

You forgot end after the isActive == false statement.

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
end)

Try this code.

I will test it tomorrow, pretty tired right now

1 Like

Okay I decided to get on, same thing happens. It doesn’t work.