Can't Use Multiple Keycards

Heya I am making keycard doors for my headquarters, one is only available to be accessed with one card. And another is only accessed with 2 cards, the last is accessed with 3 cards. The last two don’t/didn’t work becuse originally I tried this:

local model = script.Parent
local detector = model:WaitForChild("Detector")
local center = model:WaitForChild("CenterPiece")
local sound = center:WaitForChild("Sound")

local open = false

detector.Touched:Connect(function(hit)
    if hit.Name == "Handle" then
        if hit.Parent.Name == "Regular Keycard" then
            if hit.Parent.Name == ("Special Keycard") then
                if hit.Parent.Name == ("Owner Keycard") then
                    if not open then
                        open = true
                        for i, v in pairs(model:GetDescendants()) do
                            if v.Parent.Name == "Door" then
                                v.CanCollide = false
                                v.Transparency = 1
                            end
                        end
                        center.CanCollide = false
                        sound.TimePosition = 0.4
                        sound:Play()
                        wait(2)
                        for i, v in pairs(model:GetDescendants()) do
                            if v.Parent.Name == "Door" then
                                v.CanCollide = false
                                if v.Material ~= Enum.Material.Glass then
                                    v.Transparency = 0
                                else
                                    v.Transparency = 0.5
                                end
                            end
                        end
                        center.CanCollide = true
                        open = false
                    end
                end
            end
        end
    end
end)

And realized wait a second, I can’t do it with making 3 names for one keycard, or whatever came in my mind… Then I tried this:

local model = script.Parent
local detector = model:WaitForChild("Detector")
local center = model:WaitForChild("CenterPiece")
local sound = center:WaitForChild("Sound")

local open = false

local tools = {"Regular Keycard", "Special Keycard", "Owner Keycard"}

detector.Touched:Connect(function(hit)
    if hit.Name == "Handle" then
        if table.find(tools, hit.Parent.Name) then
            if open == false then
                open = true
                for i, v in pairs(model:GetDescendants()) do
                    if v.Parent.Name == "Door" then
                        v.CanCollide = false
                        v.Transparency = 1
                    end
                end
                center.CanCollide = false
                sound.TimePosition = 0.4
                sound:Play()
                wait(2)
                for i, v in pairs(model:GetDescendants()) do
                    if v.Parent.Name == "Door" then
                        v.CanCollide = true
                        if v.Material ~= Enum.Material.Glass then
                            v.Transparency = 0
                        else
                            v.Transparency = 0.5
                        end
                    end
                end
                center.CanCollide = true
                open = false
            end
        end
    end
end)

I used here tables, which fixed the collision issue, yet didn’t allow me to use 3 tools to open the door, only the first one made it open (Regular Keycard) so now I’m confused why none of this worked. If anyone could help me, that would be great!!

Screenshot of where the tools are, and what their names are:
image

1 Like

Hey I’m sorry but I tried a couple different ways and this wasn’t helping because it’s literally no different from what I used. I used the correct table format that it shows on the page:

local tools = {
	"Regular Keycard",
	"Special Keycard",
	"Owner Keycard"
}

And it just didn’t work, if anyone else could really help me fix this issue, that would be really great.

Are you sure the tool names are the exact same as the names in the table? Maybe check if theres an extra space at the end of the Tool names

Heya phxtn! Yes that would certainly be a good cause for it not to work but we checked it multiple times but just incase my slow brain didn’t catch it after staring at it a couple times screenshot of where the tools are & what there names are:
image

Check for whitespace at the end of the Tool names