Basically, I’m making a keycard door that scans the player’s backpack for a tool, the problem is when I use the proximity prompt, the door does detect it as the player does not have clearance. I am using a table for the different clearences.
Here’s the part of the script that detects the players backpack for the key:
ProximityPrompt.Triggered:Connect(function(player)
if bool and clearance[player.Backpack:FindFirstChild(clearance) or player.Character:FindFirstChild(clearance) ] then
bool = false
script.Parent.AccessGranted:play()
script.Parent.Parent.Light1.BrickColor = BrickColor.new("Lime green")
script.Parent.Parent.Light2.brickColor = BrickColor.new("Lime green")
ProximityPrompt.Enabled = false
openDoor()
wait(1)
script.Parent.Parent.Light1.BrickColor = BrickColor.new("Lily white")
script.Parent.Parent.Light2.brickColor = BrickColor.new("Lily white")
ProximityPrompt.Enabled = true
bool = true
elseif bool2 and not clearance[player.Backpack:FindFirstChild(clearance) or player.Character:FindFirstChild(clearance) ] then
bool2 = false
script.Parent.Parent.Light1.BrickColor = BrickColor.new("Really red")
script.Parent.Parent.Light2.brickColor = BrickColor.new("Really red")
ProximityPrompt.Enabled = false
wait(1)
script.Parent.Parent.Light1.BrickColor = BrickColor.new("Lily white")
script.Parent.Parent.Light2.brickColor = BrickColor.new("Lily white")
ProximityPrompt.Enabled = true
bool2 = true
end
end)
Is this the line facing the error? if so, use :Play() instead of :play()
Also, you can’t just do :FindFirstChild(clearance), you have to specifically look through the table and see if the index is there. A simple for loop will get the job done.
Well it does sort of work, however when you first open it prints the statement for insufficient clearance (basically not the right card) , but then it opens and is then stuck in a loop of being open and closed.
My way is correct because there are values associated with each index. Look at L1, it’s set to false so your code will not know that because it is an array.
As shown in the video, when the card is first used it plays the access denied sequence, but then switches to the access granted one and is frozen there for a few seconds before going back to normal.