How to find a string in a table and check a bool

Hi! I am trying to make a door open slowly when it is touched with a keycard, these keycards are all named in a Clearance local. I am having problems with trying to make the hit.Parent check if the name that hit is set to true in a table. How would I go about this?

local TweenService = game:GetService("TweenService")
local TweenPart = script.Parent.Door

local TweenInformation = TweenInfo.new(
	
	1, -- Length of each Tween Session.
	
	Enum.EasingStyle.Linear, -- EasingStyle of the Tween Session.
	
	Enum.EasingDirection.Out, -- EasingDirection of the Tween Session.
	
	0, -- How many times the Tween Session will repeat.
	
	false, -- Reverse the Tween Session (Turn into the new given Properties, and go turn back into the normal part's properties.)
	
	0 -- Delay of a Tween Session.
	
	)
	
local Clearance = {
["Level-Omni"] = true, 
["Level-5"] = true, 
["Level-4"] = true,
["Level-3"] = true,
["Level-2"] = true,
["Level-1"] = false,
["MTF Access Card"] = true,
["Armory Card"] = false,
["RD Card"] = true,
["Defective Card"] = true,
["CD Card"] = false,
["CE Card"] = false,
["SCP - 005"] = true,
["E&T Card"] = false
}

local TweenGoals = {	

	Position = Vector3.new(3.701, 5.675, 0)
	
	
}

local TweenAnimation = TweenService:Create(TweenPart, TweenInformation, TweenGoals)

script.Parent.Parent.Keycard.Touched:Connect(function(hit)
	print(hit.Parent)
	if hit.Parent == type(clearance) then
			
			while wait(0.1) do
			TweenAnimation:Play()
			end
		
	end
	
end)

Probable Solution?


if Clearance[hit.Parent.Name] then

Pretty sure this is what you’re looking for. Also that while loop is infinite, which causes TweenAnimation to play every 0.1 seconds.

3 Likes