I want to make a door open based on whether a player has a keycard in their inventory. However, even when I take the card out of the players inventory, they are still able to open the door. Here is what I have used:
reader2.ProximityPrompt.Triggered:Connect(function(player)
for k,n in pairs(player.Backpack:GetChildren()) do
if n:FindFirstChild("Keycard") then
granted:Play()
openclose()
else
denied:Play()
end
end
end)
I think that the issue may be with function(player), but I’m not sure.
reader2.ProximityPrompt.Triggered:Connect(function(player)
if player.Backpack:FindFirstChild("Keycard") then
granted:Play()
openclose()
else
denied:Play()
end
end)
You were iterating through the backpack table and looking inside children of the backpack. You should be looking in the Backpack.