i am trying to make a script for to check if a person is or is not admin
local player = script.Parent.Parent.Parent.Name local players_allowed = {jeremqpmfpi} wait(1) for i, v in pairs{players_allowed} do if player ~= players_allowed[1] then print("player is not admin") else print("player is admin") end end
note: it is in the player gui and i am jeremqpmfpi
Arrays start counting from 0, so your username in the array is at position 0. For example, [A, B, C, D], A would be index 0, B index 1, C index 2 etc.
When you call players_allowed[1] you're calling the index after your username, which is undefined.
You could look up how to integrate over an array to make your code a bit cleaner :)
This isn't the best method but it's an ok example...
for index, player in ipairs(players_allowed) do //notice not curly brackets, also notice "ipairs" is used for arrays where as "pairs" is used for dictionaries (i stands for indexed) if player == player_allowed[i] then//this will compare the username to every value in the list print(player ... " Is an admin") end end
Apologies if I've missed something I haven't done pus in a while and I'm on mobile lol