Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

i get both player is admin and not admin, what?

Asked by 3 years ago

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", "gosubtojerem_qpmfpi"}
print(players_allowed)

wait(1)
for index, player in pairs(players_allowed) do
    if player == players_allowed[1] then
        print("player is admin")
    end
    if player ~= players_allowed[1] then
        print("player is not admin")
    end
end

note:

it is in the player gui
i am jeremqpmfpi
i tried adding brackets to the "players_allowed[1]" in the if statements
also lua does tables 1 - 2 - 3 not 0 - 1 - 2 - 3

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

It won't really work cuz it checks the player once. Instead, you can do

local player = script.Parent.Parent.Parent.Name
local players_allowed = {"jeremqpmfpi", "gosubtojerem_qpmfpi"}

wait()

for i, p in pairs(players_allowed) do
    if p.Name == players_allowed[1] then
        print("Admin")
    else
        print("Player")
end
Ad

Answer this question