Basic Admin Essentials - Ranking Commands

I am trying to make a demote command for Basic Admin Essentials.

However, every time I run the command, it doesn’t work.
I get no errors tho.

Plugin Script:

local Plugin = function(...)
	local Data = {...}
	
	-- Included Functions and Info --
	local remoteEvent = Data[1][1]
	local remoteFunction = Data[1][2]
	local returnPermissions = Data[1][3]
	local Commands = Data[1][4]
	local Prefix = Data[1][5]
	local actionPrefix = Data[1][6]
	local returnPlayers = Data[1][7]
	local cleanData = Data[1][8] -- cleanData(Sender,Receiver,Data)
	-- Practical example, for a gui specifically for a player, from another player
	-- cleanData(Sender,Receiver,"hi") -- You need receiver because it's being sent to everyone
	-- Or for a broadcast (something everyone sees, from one person, to nobody specific)
	-- cleanData(Sender,nil,"hi") -- Receiver is nil because it is a broadcast
	
	-- Plugin Configuration --
	local pluginName = 'demote'
	local pluginPrefix = Prefix
	local pluginLevel = 3
	local pluginUsage = "<User(s)>" -- leave blank if the command has no arguments
	local pluginDescription = "Demotes a player to the previous rank below theirs"
	
	local canRankMultiplePlayers = false -- Whether or not multiple people can be specified. For example, if
	-- you want admins to be able to do :demote player1, player2, player3 or not. Useful if group is prone to
	-- admin abuse or anything like that
	local groupToRank = 12961397 -- The ID of the group you want to rank people in
	
	local function getPreviousRank(currentRank)
		return math.clamp(currentRank - 1, 1, 254)
	end	
	
	local function getRankInGroup(player)
		local success, res = pcall(function()
			return game:GetService("GroupService"):GetGroupsAsync(player.UserId)
		end)
		if success and res then
			for _,v in pairs(res) do
				if v.Id == groupToRank then
					return v.Rank
				end
			end
			return 0
		else
			return nil
		end
	end

	local rankingModule = require(game:GetService("ServerScriptService"):WaitForChild("RankingModule"))
	local function pluginFunction(args) 
		local player = args[1]
		if args[3] then
			local toRank = returnPlayers(player, args[3])
			if toRank then
				if not canRankMultiplePlayers and #toRank > 1 then
					remoteEvent:FireClient(player, "Hint", "You cannot demote more than one player at a time.")
					return
				end
				for _,v in pairs(toRank) do
					if v ~= player then
						local playerRankInGroup = getRankInGroup(v)
						local adminRankInGroup = getRankInGroup(player)
												
						if playerRankInGroup and adminRankInGroup then
							if playerRankInGroup < adminRankInGroup then
								local rankToSet = getPreviousRank(playerRankInGroup)		
								rankingModule.demote(v)
							end
						end
					end
				end
				remoteEvent:FireClient(player, "Hint", "Rank Change Attempted", "Attempted to demote "..#toRank.." player(s).")
			end
		end
	end
	
	-- Return Everything to the MainModule --
	local descToReturn
	if pluginUsage ~= "" then
		descToReturn = pluginPrefix..pluginName..' '..pluginUsage..'\n'..pluginDescription
	else
		descToReturn = pluginPrefix..pluginName..'\n'..pluginDescription
	end
	
	return pluginName,pluginFunction,pluginLevel,pluginPrefix,{pluginName,pluginUsage,pluginDescription}
end

return Plugin

Ranking Module Script:

local GlitchURL = ""

local groupService = game:GetService("GroupService")
local groupInfo = groupService:GetGroupInfoAsync(12961397)

function getNextRank(CurrentRank)
	for i = 1, #groupInfo.Roles do
		local RankId = groupInfo.Roles[i].Rank
		if RankId > CurrentRank then
			return RankId
		end
	end	
end

function getPreviousRank(CurrentRank)
	table.sort(groupInfo.Roles, 	function(a,b) return a.Rank > b.Rank end)
	for i = 1, #groupInfo.Roles do
		local RankId = groupInfo.Roles[i].Rank
		if RankId < CurrentRank then
			return RankId
		end
	end	
end

function rankUser(UserId,RoleId)
	game:GetService("HttpService"):GetAsync(GlitchURL .. "ranker?userid=" .. UserId .. "&rank=" .. RoleId)
end

local module = {}

module.promote = function(user)
	local PlayerToRank = user
	local PlayerCurrentRank = PlayerToRank:GetRankInGroup(12961397)
	local RankId = getNextRank(PlayerCurrentRank)
	rankUser(PlayerToRank.UserId, RankId)
end

module.demote = function(user)
	local PlayerToRank = user
	local PlayerCurrentRank = PlayerToRank:GetRankInGroup(12961397)
	local RankId = getPreviousRank(PlayerCurrentRank)
	rankUser(PlayerToRank.UserId, RankId)
end

return module

plz help me. c:

1 Like

Never used this module before, but have you checked the rank you set the commands to? And do you have any errors in your output?

1 Like

No errors.
I checked the rank I set it to.

1 Like

I’m not sure then. Sorry, I haven’t been of much help, I’m not very familiar with this module nor its framework, as I use my own. If you’re interested I can help you make one with my methods instead.

1 Like

Did you ensure your glitch or VPS server is online & have provided a working roblox security cookie??

1 Like