Hi guys. I would be really happy if you can explain me why this is not working.
this is the code:
local door = script.Parent
local vips = {"DNF2307","Roox4"} -- those are the arrays
local check = false
function checkVip(hit)
local humanoid = hit.Parent:FindFirstChild("Humanoid")
for i = 1, #vips do
if hit.Parent.Name == vips[i] then
check = true
elseif check == false then
humanoid.Health = 0
end
end
end
door.Touched:connect(checkVip)
So basically i made a vip door so only the people who have their name in the arrays are able to get through. The problem with this is that if someone who has their name in the arrays on the second place it will kill him. If on the first it's ok. And it also prints that the humanoid is a nil value which I don't understant too. If anyone of you know the solution please tell me. Thanks.

1 comment
Why not set up a variable to show that it found the person as a VIP or not, and run lines 12-13 afterwards?