I made this admin commands script and I was wondering how I can use group ranks to add admins. My script is below and the admins are represented by a table for now.
local Admins = {
"bootsareme",
"TestPlayer123"
}
local Prefix = "!"
local Players = game:GetService("Players")
local Commands = {}
Commands.adminconsole = function(Sender, Arguments)
game.ReplicatedStorage.OpenAdminConsole:FireClient(Sender)
end
local function IsAdmin(Player)
for _,Admin in pairs (Admins) do
if type(Admin) == "string" and string.lower(Admin) == string.lower(Player.Name) then
return true
elseif type(Admin) == "number" and Admin == Player.UserId then
return true
end
end
return false
end
local function ParseMessage(Player,Message)
Message = string.lower(Message)
local PrefixMatch = string.match(Message,"^"..Prefix)
if PrefixMatch then
Message = string.gsub(Message,PrefixMatch,"",1)
local Arguments = {}
for Argument in string.gmatch(Message,"[^%s]+") do
table.insert(Arguments,Argument)
end
local CommandName = Arguments[1]
table.remove(Arguments,1)
local CommandFunc = Commands[CommandName]
if CommandFunc ~= nil then
CommandFunc(Player,Arguments)
end
end
end
Players.PlayerAdded:Connect(function(Player)
Player.Chatted:Connect(function(Message,Recipient)
if not Recipient and IsAdmin(Player) then
ParseMessage(Player,Message)
end
end)
end)
I want to do something with table.insert(player.Name)
but I am not aware of any API function that gets the player name from any group ranks. The only thing I am aware of is player:GetRankInGroup(12345)
. That is assuming that the player is active and in the server. I can try to do:
local Admins = {}
game.Players.PlayerAdded:Connect(function(player)
if player:GetRankInGroup(12345) == 254 then
table.insert(Admins, player.Name)
end
end)
I am aware of this method but this is highly inefficient to implement due to other scripts. Is it possible to look at the metadata for a player and make a api call from groups.roblox.com? or is the above method the only way?