so in my script, when you join the game the following code runs:
local Admins = {"PutNameHere", "cruizer_snowman"} game.Players.PlayerAdded:connect(function(Player) Player.CharacterAdded:connect(function(Char) if Player:GetRankInGroup(2832687) == 3 then -- just a double check if Player.Name == Admins then -- checks if the players name is in the table of Admins game.ReplicatedStorage.AdminPannel:Clone() game.ReplicatedStorage.AdminPannel.Parent = Player.PlayerGui end end end) --------------------------------------------- local Folder = Instance.new("Folder", Player) Folder.Name = "leaderstats" --------------------------- local Warnings = Instance.new("IntValue", Player) Warnings.Name = "Warnings" Warnings.Value = 0 end)
to be honest, im not that great with tables :/ any help would be much appreciated!
Incapaz's idea is good, however he forgot to mention that you would need to turn your table into a dictionary table.
A dictionary table looks like this:
local t = { Key = "value" }
or
local t = { ["Key"] = "value" }
So your table should look like this:
local Admins = { PutNameHere = true, cruizer_snowman = true, }
And your full code, like this:
local Admins = { PutNameHere = true, cruizer_snowman = true, } game.Players.PlayerAdded:connect(function(Player) Player.CharacterAdded:connect(function(Char) if Player:GetRankInGroup(2832687) == 3 then -- just a double check if Admins[Player.Name] then -- checks if the players name is in the table of Admins game.ReplicatedStorage.AdminPannel:Clone() game.ReplicatedStorage.AdminPannel.Parent = Player.PlayerGui end end end) --------------------------------------------- local Folder = Instance.new("Folder", Player) Folder.Name = "leaderstats" --------------------------- local Warnings = Instance.new("IntValue", Player) Warnings.Name = "Warnings" Warnings.Value = 0 end)
Lines 3 and 4. Change :connect to :Connect, :connect is deprecated.
Line 6. You’re checking if the player’s name equals an entire table, which isn’t possible. So do this:
if Admins[Player.Name] then
With any admin system you should be using the UserId as this will never change.
There are lots of ways you can check if the player is in the admin list but the simpler method would be to use a dictionary as you can look up the index quickly.
Lastly you also clone the AdminPannel but the clone is not used meaning you just change the parent of the admin panel. You also should probably put this admin gui in storage as normal player do not need it replicated to them.
Example:-
local Admins = { -- format player id = name -- name is just a place holder [193019473] = "cruizer_snowman" } game.Players.PlayerAdded:connect(function(Player) Player.CharacterAdded:connect(function(Char) if Player:GetRankInGroup(2832687) == 3 then -- index will be nil if not found if Admins[Player.UserId] then -- clone and parent the gui game.ReplicatedStorage.AdminPannel:Clone().Parent = Player.PlayerGui end end end) --------------------------------------------- local Folder = Instance.new("Folder", Player) Folder.Name = "leaderstats" --------------------------- local Warnings = Instance.new("IntValue", Player) Warnings.Name = "Warnings" Warnings.Value = 0 end)
A better Idea would be to only connect the add admin panel function on CharacterAdded for admins only meaning you would only check if they are admin once.
I hope this helps.