What I'm trying to do is make a card access door, which when you touch your card against the scanner, it checks a value inside the card and if it is in "access" it unlocks a door.
local access = { 001, } script.Parent.Touched:connect(function(part) if part.Parent:FindFirstChild("CardNumber") ~= nil then if access[part.Parent.CardNumber.Value] then local door = script.Parent.Parent.Parent.Door:GetChildren() script.Parent.Parent.Card.Transparency = 0 script.Parent.Parent.Card.DecalA.Transparency = 0 script.Parent.Parent.Card.Decal.Transparency = 0 for i,v in pairs(door) do v.CanCollide = false end wait(3) script.Parent.Parent.Card.Transparency = 1 script.Parent.Parent.Card.DecalA.Transparency = 1 script.Parent.Parent.Card.Decal.Transparency = 1 for i,v in pairs(door) do v.CanCollide = true end end end end)
There are no errors nor output.
Dictionaries
The issue with how you have it set up is that you want to check if a table contains something else. Lua doesn't have an inherent way to do that, but what you can do instead is test to see if the key matches to a value.
Consider a table where you have your card numbers as keys instead:
allow = { [002] = true; [003] = true; [005] = true; [007] = true; [011] = true; [013] = true; }
In this case, you can check if your card is allowed by doing what you're already doing, because it will either resolve to true
or nil
.
You must make sure that you're using the same type of value for your key. If the value you're trying to check for is a string, make sure that the keys are strings. Lua equality means that different datatypes are different.