Help with simple proximity prompt Drawer

This is true. If the script for the proximity prompt is not contained within a Script, then it won’t fire as LocalScripts only work in certain folders and containers.

yes I understand that but the code is not contained within a local script.

wait where is the script located because thats all I can think of.

If “Drawer 1” is referring to a model, keep in mind that Models do not have a CanCollide or Transparency property. BaseParts have these properties, so you’d either need to directly reference any BaseParts inside of the drawers or utilize a loop in order to change all of them:

For example, that means this:

drawer.Transparency = 1
drawer.CanCollide = false

Might turn into this:

for _, item in ipairs(drawer:GetChildren()) do -- Gets everything on first layer of the drawer

    if item:IsA("BasePart") then -- Checks if an item inside is a BasePart
        item.CanCollide = false -- Adjusts its CanCollide
        item.Transparency = 1 -- Adjusts its Transparency
    end
end

It’s located inside of [“Drawer 1”]

Ah, I see thank you I will try that and see what happens.

Hmm if there isn’t any errors you could also do object references a bit differently like
local drawer = script.Parent
local proxprompt = drawer:FindFirstChildOfClass("ProximityPrompt)

Can you try running:

proxprompt.Triggered:Connect(function()
    print("Triggered")
end

just to see if the event is firing?

Correct me if I’m wrong but I’m supposed to be able to press E and that triggers the event. But I don’t even see the proximity prompt like nothing at all happens. So doing this wouldn’t help? (may be wrong im pretty bad at scripting)

Is the ProximityPrompt parented to a part or model?

The proximity prompt is located inside a model.

If you aren’t seeing the ProximityPrompt in the first place it’s likely that it’s being obstructed by other parts. You can disable the RequiresLineOfSight property in order to ensure that it appears whenever you’re in range.

1 Like

ProximityPrompts are only visible when they are parented to a Part.

This is false. The ProximityPrompt Developer Hub page mentions the different Instances it can be parented to (Part, Model, Attachment).

However, it’s not always preferred to have it inside of a Model since it’s not as accurate as using parts & attachments to determine where it will appear, as shown by the following example:

Can you elaborate on that please?

Oh, my bad. I’ve had issues with parenting them to things other than Parts so my mistake.

Can you please show me the script used?

I don’t have that place anymore but it was essentially this:

local ProximityPrompt = script.Parent

local count = 0

ProximityPrompt.TriggerEnded:Connect(function()
    count += 1

    warn("Attachment ProximityPrompt has been activated "..count.." times!")
end)

If the updated code you’re using for your game isn’t showing anything in the Output, whether errors or the print statements you added, I’m not sure what else could be causing it to work improperly if the script is enabled.

To begin with, in the locals, what do you use “game” for? It would be easier if you put the script inside the drawer model, and so instead of using game you use for example “script.Parent.Parent…” it’s easier and also has a big difference to what you put. I think the solution is to change what you did. Also, you used a number to define CanCollide, your code has many errors, I’ll solve it for you here!:

– First move your script inside the Drawer

– Locals
local proxprompt = game.Workspace.everything.Drawer:FindFirstChild(“Drawer 1”).ProximityPrompt
local drawer = game.Workspace.everything.Drawer:FindFirstChild(“Drawer 1”)
local opendrawer = game.Workspace.everything.Drawer:FindFirstChild(“Drawer 2”)

– Script**Preformatted text**
opendrawer.Transparency = 1
opendrawer.CanCollide = false
drawer.Transparency = 0
drawer.CanCollide = true

proxprompt.Triggered:Connect(function()
drawer.Transparency = 1
drawer.CanCollide = false
opendrawer.Transparency = 0
opendrawer.CanCollide = true
wait(3) – Cooldown
drawer.Transparency = 0
drawer.CanCollide = true
opendrawer.Transparency = 1
opendrawer.CanCollide = false
end)

– End Of script

Bro He made ultra abnormal mistakes like not using “true” or “false” to talk about CanCollide, it was not necessary to say all that :skull: :skull: :skull: :skull: