Basic Admin Essentials Command Not Working

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    Have this send an http request.
  2. What is the issue? Include screenshots / videos if possible!
    It only prints “Function1”, and my username.
  3. What solutions have you tried so far?
    I have attempted to debug the code, and mess with the arguments a bit.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

--[[
	
	 ____                                   
	/\  _`\                    __           
	\ \ \L\ \     __      ____/\_\    ___   
	 \ \  _ <'  /'__`\   /',__\/\ \  /'___\ 
	  \ \ \L\ \/\ \L\.\_/\__, `\ \ \/\ \__/ 
	   \ \____/\ \__/.\_\/\____/\ \_\ \____\
	    \/___/  \/__/\/_/\/___/  \/_/\/____/
	                                        
	            
	Admin Essentials v2
	Plugin Documentation
	*coming soon^tm
	
	If you have any questions regarding Plugins, contact TheFurryFish.
	
--]]
local Http = game:GetService("HttpService")
local config = {
	url = "REDACTED FOR SECURITY",
	auth = 'REDACTED FOR SECURITY'
}
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 = 'logtraining'
	local pluginPrefix = Prefix
	local pluginLevel = 1
	local pluginUsage = "cohostid" -- leave blank if the command has no arguments
	local pluginDescription = "A training log."
	
	-- Example Plugin Function --
	local function pluginFunction(Args) -- keep the name of the function as "pluginFunction"
		print("Function1")
		local Player = Args[1]
		print("Function PlrDefined")
		print(Player.Name)
		print(Args[2])
		local SendTable = {
			hostid = Player.userId,
			cohostname = Args[2],
			cohostid = game.Players:GetUserIdFromNameAsync(Args[2]),
			userarray = {}
		}
		print("Function2")
		for i,v in pairs(game.Players:GetPlayers()) do
			if(v:GetRankInGroup(Also Redacted) >= 96) then
				table.insert(SendTable.userarray, v.userId)
			end
		end
		print("Function3")
		local request = Http:RequestAsync({
			Url =  config.url .. '/logtraining',
			Method = "POST",
			Body = Http:JSONEncode(SendTable),
			Headers = {
				["Content-Type"] = "application/json",
				['authorization'] = config.auth
			}
		})
		print(request)
		print("Function4")
	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

What exactly is the issue you’re encountering? Please provide more detail so we can better help you.

Basically, it doesn’t get past printing my name, so it’s getting stuck when it’s trying to print(Args[2]), but there is no error in the console, and when I run the command, the admin tells me there was an error, but not what the error was.

Okay, the only real way to discover what’s happening is to debug each chunk of code. If you wrap sections in a pcall, for example,

local success, err = pcall(function()
        print("Function2")
		for i,v in pairs(game.Players:GetPlayers()) do
			if(v:GetRankInGroup(Also Redacted) >= 96) then
				table.insert(SendTable.userarray, v.userId)
			end
		end
end)

You can then see if there was an error in that section or not, so your code would become something like:

local success, err = pcall(function()
        print("Function2")
		for i,v in pairs(game.Players:GetPlayers()) do
			if(v:GetRankInGroup(Also Redacted) >= 96) then
				table.insert(SendTable.userarray, v.userId)
			end
		end
end)
if not success then warn(err) end
2 Likes