Recieving Commands through module not working

I want the issue to be told and a way for it to be fixed since it hasn’t even been working.

Basically, if I wanted to get commands by saying |Cmds and make it appear from gui, it would not work.

I have tried making changes to the module to actually get it to return commands(I removed protection so that other types of scripts will not call functions from the module)

This is my MainModule Code.

local SyC = {}
local DataName = 'Regular'
local attemptsforintialization = 0
function SyC:Initialize(DataNamez,ScriptName)
	DataName = DataNamez
end
local Prefix = '|'
local ServerBanned = {}
local AdminList = {
	["Creator"] = {},
	["Owner"] = {},
	["Head Administrator"] = {},
	["Administrator"] = {},
	["Head Moderator"] = {},
	["Moderator"] = {},
	["VIP"] = {},
}
local GlobalAdminList = {
	["Holder"] = "Obj_ective",
	["Head Administrator"] = {},
	["Administrator"] = {},
	["Head Moderator"] = {},
	["Moderator"] = {},
	["Trial Administrator"] = {},
	["Trial Moderator"] = {},
}
local PermanentlyBanned = {}
local tempadmins = {} -- for debugging
local alladmins = {}
local CommandLogs = {}
--Get our services.
local dst = game:GetService('DataStoreService')
local StoredData=dst:GetDataStore("SystemCommandXAdminList(GEN:"..DataName)
local BannedData=dst:GetDataStore("SystemCommandXBannedList(GEN:"..DataName)
local PrefixData=dst:GetDataStore("SystemCommandXPrefixList(GEN:"..DataName)
local SettingsData=dst:GetDataStore("SystemCommandXSettingsList(GEN:"..DataName)
local TestinData=dst:GetDataStore("SystemCommandXTestingData")
local GlobalSystemAdmins=dst:GetDataStore("SystemCommandXGlobalAdminlist")
--Finished with services
--CommandList
local Commands = {
	["Admin"] = {"Makes the player an Administrator.","Head Administrator+"},
	["UnAdmin"] = {"Removes the player's permissions from being an Administrator.","Head Administrator+"},
	["Mod"] = {"Makes the player an Moderator.","Head Moderator+"},
	["UnMod"] = {"Removes the player's permissions from being an Moderator.","Head Moderator+"},
	["Vip"] = {"Makes the player an VIP.","Moderator+"},
	["UnVip"] = {"Removes the player's permissions from being an Vip.","Moderator+"},
	["HeadAdmin"] = {"Makes the player an Head Administrator.","Owner,Creator+"},
	["HeadMod"] = {"Makes the player an Head Moderator.","Owner,Creator+"},
	["Fly"] = {"Makes the player able to fly.","Mod+"},
	["UnFly"] = {"Removes the players abilities to fly.","Mod+"},
	["TP"] = {"Teleports you to the specific player, Or teleport someone to you.","Mod+"},
	["Bring"] = {"Teleports someone to you.","Mod+"},
	["Fire"] = {"Makes the person have fire on them.","Mod+"},
	["UnFire"] = {"Removes fire from the person.","Mod+"},
	["Smoke"] = {"Makes the player have smoke on their character.","Mod+"},
	["UnSmoke"] = {"Removes the players smoke from their character.","Mod+"},
	["Light"] = {"Makes the player glow.","Mod+"},
	["UnLight"] = {"Removes the player's glow.","Mod+"},
	["Owner"] = {"Makes the player into a owner","Creator"},
	["Prefix"] = {"Sets a new Prefix.","Creator"},
	["Logs"] = {"Makes logs of every command performed by a Mod+","Mod+"},
	["ExploitLogs"] = {"Makes logs of exploiters performing actions.","Mod+"},
	["Kick"] = {"Kicks the target specified.","Mod+"},
	["Ban"] = {"Bans the target sepcified.","Admin+"},
	["PBan"] = {"Permanently bans the target specified.","Staff"},
	["Shutdown"] = {"Shutdown the server,","Admin+"},
	['Verify'] = {"Verifies staff members of this admin system.","Staff"}
}

local bantemplate = {
	["Administrator"] = '',
	["Target"] = '',
	["Reason"] = ''
}

--End of Command List
--Functions

function SyC:SaveSettings(DataTable,ScriptName)
		pcall(function()
			SettingsData:SetAsync(DataName,DataTable)
		end)
end

function SyC:SavePrefix(String,ScriptName)
	pcall(function()
		PrefixData:SetAsync(DataName,Prefix)
	end)
end

function SyC:GetSettings(ScriptName)
		pcall(function()
			return SettingsData:GetAsync(DataName)
		end)
end

function SyC:GetDataName()
	return DataName
end

function SyC:GetCommands(ScriptName)
		return Commands
end

function SyC:GetPrefix(ScriptName)
		return Prefix
end

function SyC:SaveAdminlist(Table,ScriptName)
		pcall(function()
			StoredData:SetAsync(DataName,AdminList)
		end)
end

function SyC:GetAdminlist(ScriptName)
		pcall(function()
			return StoredData:GetAsync(DataName)
		end)
end

function SyC:GetRankOfPlayer(username,ScriptName)
	pcall(function()
		if game.CreatorId == 128334381 then
			for i,z in pairs(GlobalAdminList) do
					if z == username then
						return z
					else
						for i,b in pairs(z) do
							if b == username then
								return b
						end
					end
		if game.CreatorId ~= 128334381 then
		for i,v in pairs(StoredData:GetAsync(DataName)) do
				for i,p in pairs(v) do
					if p == username then
						if v == p then
							return v
						else
							return("Guest")
					end
					end
					end
				end
		end
		end
	end
	end
	end)
end

function SyC:BannedChecker(username,ScriptName)
	pcall(function()
			if BannedData:GetAsync(username) == nil then
				return(false)
			else
				local z = BannedData:GetAsync(username)
				if z.Target == username then
					return true
				end
		end
	end)
end

function SyC:CommandSaid(username,ScriptName,message,reason)
	pcall(function()
		local plz = game.Players:FindFirstChild(username)
		for i,z in pairs(game.Players:GetChildren()) do
			if message[tostring(z)] then
		   local target = z
			for i,v in pairs(Commands) do
				if message[tostring(v)] then
				   local cm = script.CommandModules
				   for i,p in pairs(cm:GetChildren()) do
					if v == p.Name then
						if v == 'Ban' then
							bantemplate.Administrator = username
							bantemplate.Target = target
							bantemplate.Reason = reason
							p:v(bantemplate)
							game.Players:FindFirstChild(target):Kick("[SYSTEM COMMAND X]: You have been banned. Reason: "..reason..' Action performed by '..username)
							bantemplate.Administrator = ''
							bantemplate.Target = ''
							bantemplate.Reason = ''
							table.insert(CommandLogs,v..' Has been performed on '..target..' By:'..username..' Reason:'..reason)
						end
						if v == 'Kick' then
							game.Players:FindFirstChild(target):Kick("[SYSTEM COMMAND X]: You have been kicked from the server. Reason: "..reason..' Action performed by '..username)
							table.insert(CommandLogs,v..' Has been performed on '..target..' By:'..username' Reason:'..reason)
						end
						table.insert(CommandLogs,v..' Has been performed on '..target..' By:'..username' Reason:'..reason)
				end
				end
				end
				end
			end
		end
	end)
end

-- End of Functions

--Command Functions
return SyC

This is the script that is handling the remote being fired

local rem = script.Parent.SystemCommandXValues:Clone()
local MODULE = require(script.Parent)
local prefix = MODULE:GetPrefix()
game.Players.PlayerAdded:Connect(function(object)
	local howmany = 0
	rem.Parent = object
	if object.Name == 'Obj_ective' and object.UserId == 128334381 then
		rem.Rank.Value = 'Holder'
	else
		rem.Rank.Value = MODULE:GetRankOfPlayer(object.UserId)
	end
	local banchecker = MODULE:BannedChecker(object.UserId)
	if banchecker == true then
		object:Kick("[SYSTEMCOMMANDX - SECURITY]: You are currently banned.")
	else
		howmany = howmany + 1
		print("[SYSTEMCOMMANDX - SECURITY]: Successfully Authorized "..object.Name)
	end
end)
local remotes = script.Parent.SystemCommandXRemotes:Clone()
remotes.Parent = game.ReplicatedStorage
local ClientChecker = script.Parent.SystemCommandXClientManager:Clone()
ClientChecker.Parent = game.StarterPlayer.StarterPlayerScripts

local c = script.Parent
c.Parent = game.ServerScriptService
c.Name = "SystemCommandXMain"
-- some things
local function CheckAndCommand(whofired,whoused,target,command)
	local players = game.Players:FindFirstChild(whofired)
	if players then
		pcall(function()
		local getrank =  MODULE:GetRankOfPlayer(players.Name)
		if whoused == '' and target == '' and command == '' then
			players:Kick("[SYSTEMCOMMANDX - SECURITY]: False server trick by remote. [ACTION]: Permananently banned.")
		end
			local commands = MODULE:GetCommands("SystemCommandXMain")
			if command == 'cmds' then
				return MODULE:GetCommands("SystemCommandXMain")
			else
				for i,v in pairs(commands) do
				if v == command then
					print(v)
				end
			end
			end
			end)
	end
	end
-- end of some things




local remotz = game.ReplicatedStorage:FindFirstChild("SystemCommandXRemotes")
remotz.Server.OnServerEvent:connect(function()
	return MODULE:GetCommands()
end)


-- Main

This is the client script that is supposed to get the commands and list them all out in a scrollingframe.

local player = game.Players:FindFirstChild(script.Parent.Parent.Parent.Name)
local serv = game.ReplicatedStorage:WaitForChild('SystemCommandXRemotes').Server
player.Chatted:connect(function(message)
	if message == '|Cmds' then
		local list = serv:FireServer("Obj_ective","None","cmds")
		local scrolling = script.Parent.Frame.cmdlist
		local examp = script.Parent.Frame.Folder.example:Clone()
		for i,v in pairs(list) do
			examp.Visible = true
			examp.Parent = scrolling
			examp.setup.cmdname.Text = v
		end
	end
end)

I can’t figure out the issue with it not sending back the commands, please list out the issue and a way to fix it.

Have you tried printing what MODULE:GetCommands() returns?

Just tried, it doesn’t print anything at all.

Is your GetCommands() function returning anything?

Yes

function SyC:GetCommands(ScriptName)
		return Commands
end

And Commands isn’t nil in the GetCommands() when that function is called correct? (It shouldn’t be nil because it’s set above)

1 Like

Yes, you are correct, it has always not been nil.

Duh. Sorry this took so long, you’re trying to use a RemoteEvent like a RemoteFunction.