local Door = script.Parent
function onTouch(Brick)
local Player = Brick.Parent:findFirstChild("Humanoid")
if(Player ~= nil) then
local TShirt = Player.Parent:findFirstChild("Shirt Graphic")
if TShirt.Graphic == "http://www.roblox.com/asset/?version=1&id=1028594" then
Door.CanCollide = false
Door.Transparency = 0.5
Door.BrickColor = BrickColor:Random()
wait(2)
Door.CanCollide = true
Door.Transparency = 0
Door.BrickColor = BrickColor:Random()
else Player.Health = 0
end
end
end
Door.Touched:Connect(onTouch)
So my code checks if the player has this exact t shirt and if the player has it will make the player able to pass through a door. This works. However when a player doesnt have the exact t shirt it is meant to kill the player. This doesnt work. So when i walk into the door without the t shirt it just says "Workspace.Part.Script:7: attempt to index nil with 'Graphic'" can anyone help with making my else statement run?

2 comments
it works now but why does it work now what is the difference that i add and "and"?
Because when there is no tshirt it will error and when you check if theres a tshirt it will not error and run else