✓ Accepted answer
I see your problem.
Let me explain the problem before giving you the answer.
If an admin touches the part, it will print Yay, but it will also print Boo. This is because you're not stopping the loop when an admin shows up. Even if you do stop the loop, the Admin may not be first in the list, so it will still print Boo. I would recommend using a function to check instead, as it will be much easier.
Example,
Admins = {
"Player1",
"FiredDusk"
}
local function CheckAdmin(name)
for i,v in pairs(Admins) do
if name == v then
return true;
end
end
return false;
end
script.Parent.Touched:connect(function(hit)
if CheckAdmin(hit.Parent.Name) then
print("Yay")
else
print("Boo")
end
end)
What this does,
This will call a function with the parameter "name". It will loop through the table, and if it finds a value in the table that matches the name, it returns true, which stops the function. If it gets through the table and no admins exist, it returns false.
Good Luck!
1 comment
try elseif hit.Parent.Name ~= v instead of else