Problem with my Admin Panel

Hello! I am trying to make a Admin Panel for a game I work for, but I have ran into a issue. I can not seem to give the panel to people, and I suspect actions would not work either.

I have the people who should have whitelist to the panel in a module here:
Screenshot 2024-04-27 005107

And I check if they have the whitelist like:
Screenshot 2024-04-27 005925

I do the exact same for checking if they can use the actual parts of the panel too, by doing table.find and seeing if they are listed in the whitelist module.

Heres how the hierarchy looks, just incase you were wondering. The script Coreshenns Panel is the one that gives the GUI, and it is placed in ServerScriptService.
image_2024-04-27_010705911

Any help is appreciated!

2 Likes

I’ve been messing around with it and I am thinking about making the whitelist just a table in the scripts, is that the only way to do this?

Have you thought about setting the permission to the players with an attribute?

if table.find(Whitelist, player.UserId) then
    player:SetAttribute("IsAdmin", true)
end

Then in your panel you can just do the following:

if player:GetAttribute("IsAdmin") then

Hope this helps :smiley: feel free to ask if you have more questions!

1 Like

You are unable to check if their username is in the table because of the way the whitelist table is setup!

In the provided whitelist table, you have values, therefore table.find() will search those variables value for the provided userId. Which its returning a table, not a userID. What I suggest doing is the following:

game.Players.PlayerAdded:Connect(function(player
    player.CharacterAdded:Connect(function()
         for _, v in pairs(Whitelist) do
               if table.find(v, player.UserId) then
                  ...
            end
        end
     end
  end

Great catch! Completely missed that

1 Like

It should be working now, correct?

Lets hope our solutions work for the OP :smiley:

you wouldn’t even need a for loop for that. you can just do the following:

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function()
        if table.find(Whitelisted["AboveAdmins"], player.UserId) then
              ...
        end
     end
  end

Unless the panel should be also given to Admins and Mods. Personally I’d just turn the whole permission thing into a dictionary:

local Whitelisted = {
    [123567] = 1,
    [58493839] = 2
    -- So on
}

if Whitelisted[player.UserId] then -- bla bla

As the aforementioned said, it would be dependent on who would have the gained access for the said admin panel.

I personally have a custom permissions module I would use for these things therefore making it much easier to manager permissions!

Anyways, this comes down to whatever the tasks requirements are for permissions.