Help with simple proximity prompt Drawer

I am in need of assistance in order to figure out what is wrong with my drawer script.

1. The goal is so that the proximity prompt will show up the player will press E and the drawer should open. It does not use Tween service or anything like that instead it uses two drawers and by changing the properties of them when the player presses E to open the drawer it should make it seem like they opened it.

2. The issue however is that nothing happens. I do not get an error in the output window at all. But when I go over to open the drawer nothing happens.

3. I tried researching more on the matter myself but I still can’t seem to figure it out. Obviously I’m doing something wrong. Keep in mind I’m still new to scripting so.

Here is the script :

local proxprompt = game.Workspace.everything.Drawer["Drawer 1"].ProximityPrompt
local drawer = game.Workspace.everything.Drawer["Drawer 1"]
local opendrawer = game.Workspace.everything.Drawer["Drawer 2"]

proxprompt.Triggered:Connect(function()
drawer.Transparency = 1
drawer.cancollide = 0
opendrawer.Transparency = 0
opendrawer.cancollide = 1

print ("Drawer opened successfully!")
-- CoolDown
wait(3)

-- Revert back to normal
drawer.Transparency = 0
drawer.cancollide = 1
opendrawer.Transparency = 1
opendrawer.cancollide = 0

print("Drawer closed successfully")

end)

It would be very helpful if someone could help me.
(Also sorry if I posted in wrong topic i’m new)

Are you getting any printed errors in your console?

The CanCollide property only accepts bools (true or false), so this would need to be changed from 0 and 1. Additionally, make sure you capitalize the property correctly so it doesn’t look for something called “cancollide” in the drawer.

No I am not getting any printed errors at all in the console. Literally nothing happens.

Are you using magnitude to find if they are in range btw?

Ah ok I will fix that error sorry i’m pretty poor at scripting and forgot about that thank you hopefully it works!

1 Like

No I’m using the proximity prompt “tool” (or whatever its called) that you can find in the workspace. I placed it inside the drawer. The premade one has a property that you should be able to change which automatically determines if the player is within range.

Oh I forgot lol, Can you show me a screenshot of the properties of the proximity prompt

It doesnt error because the script signal isnt taking place.

local proxprompt = game.Workspace.everything.Drawer["Drawer 1"].ProximityPrompt
local drawer = game.Workspace.everything.Drawer["Drawer 1"]
local opendrawer = game.Workspace.everything.Drawer["Drawer 2"]

proxprompt.Triggered:Connect(function()
drawer.Transparency = 1
drawer.CanCollide = false
opendrawer.Transparency = 0
opendrawer.CanCollide = true

print ("Drawer opened successfully!")
-- CoolDown
wait(3)

-- Revert back to normal
drawer.Transparency = 0
drawer.CanCollide = true
opendrawer.Transparency = 1
opendrawer.CanCollide = false

print("Drawer closed successfully")

end)

Try this, fixed a few Syntax and Boolean errors.

1 Like

I think the problem is that the event connector isn’t being triggered so the function isnt taking place.

If the code is contained in a LocalScript, it has to be in one of the following locations in order to be activated:

  • A Player’s Backpack , such as a child of a Tool
  • A Player’s character model
  • A Player’s PlayerGui
  • A Player’s PlayerScripts .
  • The ReplicatedFirst service

Otherwise, the events of the ProximityPrompt can still be detected from a server script if you’d like the changes to the CanCollide & Transparency properties of those Instances in the Workspace to be replicated to other players.

what is Drawer exactly because I don’t use that kind of code for object reference lol.

Didn’t solve the problem still not getting errors and still nothing happens.

ProximityPrompts doesnt need a local script since you can find reference to the player that activated it.

A drawer is in pieces of furniture you pull it out and place items in it then place it back in i’m pretty sure you must have at least 1 in your home.

No, it is not in a local script. It is supposed to be server sided and thus its in a regular script.

Wait no I meant why are you getting object reference like that. If you can tell me the path of the proximityprompt from workspace I could suggest another way to give reference to the proximityprompt. Like a screenshot of the explorer view so I can see the path to the proximity prompt.

Its workspace - Everything (model) -Drawer (model) and inside the Drawer model it has Drawer 1 and Drawer 2. Inside the drawer 1 model is where the proximity prompt is located.