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

Why is this global table not being accessed?

Asked by 7 years ago

Basically I've got one script checking to see if you are an admin, and another script is using that.

Script 1: I know that the "player" and the "AdminList" variables are working.

function isAdmin(player)
    for i,v in pairs(AdminList) do
        if v.name == player.Name then
            _G.securityAdmins[#_G.securityAdmins+1]=player.Name
            return true             
        end     
    end 
end

Script 2: If I change _G.securityAdmins (and look manually) it works... so I know it's the table having an issue.

game.Players.PlayerAdded:connect(function(player)
    player.Chatted:connect(function(msg)
        for i,v in pairs(_G.securityAdmins) do 
            if v.Name == player.Name then
                print(player.Name.." is an admin!")
                if msg:lower():sub(1,2) == "hi" then
                    print("The admin said hi!")
                end
            end
        end
    end)
end)
1
You should probably be using a ModuleScript and not _G for this. BlueTaslem 18071 — 7y

Answer this question