I've got this script to compare userId's to check if a player is on a list. but everything prints and two of the prints match but they don't print the "You're an admin " part. Why?
local admins = {"4376147","30701890"} script.Parent.PAE.OnServerEvent:connect(function(player,player1) for i,v in pairs (admins) do print(player1.userId) print(v) if v == player1.userId then print("You're an admin "..player1.Name) end end end)
You're comparing their userid (number) to a string.
Two ways to fix this:
Call tonumber() on v. Or make the values in admins numbers
local admins = {4376147, 30701890} --these are now numbers not strings script.Parent.PAE.OnServerEvent:connect(function(player,player1) for i,v in pairs (admins) do print(player1.userId) print(v) if v == player1.userId then print("You're an admin "..player1.Name) end end end)
An easier way to accomplish such a method
local admins = {4376147, 30701890} script.Parent.PAE.OnServerEvent:connect(function(player,player1) if admins[player1.userId] then --[[ code ]] end end)