Proximity Door Lock: attempt to index boolean with 'Enabled'

I am working on a Proximity Door that’s locked. When you touch a key and equip it. It allows you to unlock the door. If you unequip the key it returns back to “Locked mode”. But, I keep bumping into this error.
image

If you know anything, please mention it below. Thank you for reading! :happy1:

local tool = script.Parent
local sound = script.Sound
local Proxy1 = game.Workspace.ProximityDoor.DoorFrame.UnlockPrompt
local Proxy2 = game.Workspace.ProximityDoor.DoorFrame.Locked

tool.Equipped:Connect(function(equipped)
	Proxy1.Enabled = true
    Proxy2.Enabled = false
	sound:Play()
end)

tool.Unequipped:Connect(function(unequipped)
	Proxy1.Enabled = false
	Proxy2.Enabled = true
end)

It has to do with the Proxy2, I am supposing that this variable is boolean, due to your error message.
I suppose you have the wrong path towards the object, maybe instead of “Locked” your 2nd Proximity Prompt is called LockedPrompt, else another object or property could be called “Locked”.

2 Likes

@KJry_s is right,
Prox2 is receiving the Boolean of whether or not the Instance is locked as opposed to actually receiving the instance.

Renaming it LockedPrompt etc. Should work

2 Likes

this is becuz the proxy2 is nil meaning it dosent exists

1 Like

Actually it isn’t nil because Locked is a property of a basepart to prevent you from clicking on it in the workspace. Having children of objects be the same name as a property can cause scripts to index the property instead of the child object. This is why it retrieved a boolean instead of a child object. And the error says this: Attempt to index boolean with Enabled.

Solution:

1 Like

Unfortunately, I’ve tried to change the second Proximity’s name and checked if there is anything different.


Both proximities won’t work. I have no idea how and why. Should I create a new value for it?

Edit: It turns out I just had to change the script too. Thank you for everyone who tried to help!