local keyCards = {
Card1 = "Reisepass",
Card2 = "Fake Reisepass"
}
local borderControlSeat = workspace.BorderControlSeat
local seat = borderControlSeat.Seat
local inspectorBool = seat.InspectorBool
local keycardCheck = workspace.KeycardCheck
local cardPos1 = workspace.CardPos1
local cardPos2 = workspace.CardPos2
local tweenService = game:GetService("TweenService")
local info = TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.In)
local properties = {
CFrame = cardPos2.CFrame
}
local triggered = false
local inspectorBool = false
keycardCheck.KeycardBool.Value = false
function inspectorCheck(reisepass)
print("reisepass touched")
if seat:FindFirstChild("SeatWeld") ~= nil then
print("seat weld exists")
local inspectorChar = seat.SeatWeld.Part1.Parent
print(inspectorChar.Name.." seated")
inspectorBool = true
return inspectorChar
end
end
function sendKeycard2(fakeReisepass,inspectorChar)
print("made it this far")
fakeReisepass.Handle.Anchored = true
fakeReisepass.Handle.CFrame = cardPos1.CFrame
local tween = tweenService:Create(fakeReisepass.Handle, info, properties)
tween:Play()
wait(1.2)
local inspectorPlayer = game.Players:GetPlayerFromCharacter(inspectorChar)
fakeReisepass.Handle.Anchored = false
fakeReisepass:Destroy()
end
function sendKeycard1(Reisepass,inspectorChar)
Reisepass.Handle.Anchored = true
Reisepass.Handle.CFrame = cardPos1.CFrame
local tween = tweenService:Create(Reisepass.Handle,info,properties)
tween:Play()
wait(1.2)
local inspectorPlayer = game.Players:GetPlayerFromCharacter(inspectorChar)
Reisepass.Handle.Anchored = false
Reisepass.Parent = inspectorPlayer.Backpack
end
script.Parent.Touched:Connect(function(hit)
print("touched")
if hit.Parent.Parent:FindFirstChild("Humanoid") then
print("humanoid found")
local char = hit.Parent.Parent
local player = game.Players:GetPlayerFromCharacter(char)
print("declared char")
print("set trigger")
if hit.Parent.Name == keyCards["Card2"] then
print("found fake reisepass")
local fakeReisepass = hit.Parent
print("delcared fake reisepass")
if keycardCheck.KeycardBool.Value == false then
keycardCheck.KeycardBool.Value = true
print("set keycard bool value")
inspectorCheck()
end
if inspectorBool == true then
local inspectorChar = inspectorCheck()
print(inspectorChar.Name)
fakeReisepass.Parent = workspace
wait(0.2)
sendKeycard2(fakeReisepass,inspectorChar)
end
end
if hit.Parent.Name == keyCards["Card1"] then
local reisepass = hit.Parent
print(hit.Parent.Name)
if keycardCheck.KeycardBool.Value == false then
keycardCheck.KeycardBool.Value = true
inspectorCheck(reisepass)
end
if inspectorBool == true then
local inspectorChar = inspectorCheck()
print(inspectorChar.Name)
reisepass.Parent = workspace
wait(0.2)
sendKeycard1(reisepass,inspectorChar)
local playerId = player.UserId
local inspectorPlayer = game.Players:GetPlayerFromCharacter(inspectorChar)
local thumbType = Enum.ThumbnailType.HeadShot
local thumbSize = Enum.ThumbnailSize.Size420x420
local content, isReady = game.Players:GetUserThumbnailAsync(playerId,thumbType,thumbSize)
local reisepassGui = inspectorPlayer.PlayerGui:WaitForChild("ReisepassGui")
local avatarImage = reisepassGui.TopFrame.AvatarImage
reisepassGui.TopFrame:TweenPosition(UDim2.new(0.5, 0,0.65, 0))
reisepassGui.BottomFrame:TweenPosition(UDim2.new(0.5, 0,0.82, 0))
end
end
end
end)
Error message: Workspace.KeycardCheck.KeycardSlot.Script:86: attempt to index nil with 'Name'
This is only happening when I insert Card2 (Fake Reispass) through the key slot. Card2 successfully goes through the slot, but at the end throws the error above

6 comments
...do you actually need to use a table? you could just use variables.
That doesn't help. Post relevant responses pls
if you delete Card2 or hit.Parent 'tis gonna error lol
How should the deletion of Card2 affect Card1? I checked my backpack in game, and Card1 is there along with its counterparts
Try if hit.Parent:FindFirstChild("Card1")
no, hit is the Handle, the Parent is the Tool @Jesse