Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

why isnt this working?

if user.Name == {"MHaven1" , "Player2", "Player1"} then
print("Admin")
else
print ("Not Admin")

this will not print 'Admin' if any one of the player in the list sits in the car. please help

1 answer

✓ Accepted answer

Assuming that user.Name actually is one of the names you're trying to compare to, there are 2 main issues with your code. Firstly you're missing an end after print("Not Admin"), secondly you're trying to compare a string to a table. To compare the table to user.Name you need to look at each value of the table independantly. This can be done with the following code:

local isntAdmin=true--To keep track of whether or not the player is an admin
for i, v in pairs({"MHaven1" , "Player2", "Player1"}) do--Loop through the table
	if user.Name==v then
		print("Admin") --user.Name is an admin
		isntAdmin=false --Keep track that one of the names is equal to user.Name
	end
end
if isntAdmin then
	print("Not Admin")
end

This discussion is preserved as it was. New answers, comments, and votes are closed.