Adonis command plugin won't show up on commands list

I am trying to make an admin command that will show a GUI that just says the player’s name and the platform they are on. I am using the Adonis Loader with a client plugin because it just errors with a server plugin. I

It is probably some really obvious problem but I can’t find it.

-- This is the client plugin script

client = nil
service = nil

return function()
	client.Commands.platform = {
		Prefix = client.Settings.Prefix;	-- Prefix to use for command
		Commands = {"platform"};	-- Commands
		Args = {"player"};	-- Command arguments
		Description = "Says what platform the player is on.";	-- Command Description
		Hidden = false; -- Is it hidden from the command list?
		Fun = false;	-- Is it fun?
		AdminLevel = "Admins";	    -- Admin level; If using settings.CustomRanks set this to the custom rank name (eg. "Baristas")
		Function = function(plr,args)    -- Function to run for command
			local UserInputService = game:GetService("UserInputService")
			local isMobile = UserInputService.TouchEnabled
			local isComputer = UserInputService.KeyboardEnabled
			local isConsole = UserInputService.GamepadEnabled
			local remoteEvent = game.ReplicatedStorage.events.PlatformCommand

			for _, player in pairs(service.GetPlayers(plr, args[1])) do

				if isMobile then
					remoteEvent:FireServer("Mobile")
				elseif isComputer then
					remoteEvent:FireServer("Computer")
				elseif isConsole then
					remoteEvent:FireServer("Console")
				end
			end
		end
	}
end
-- This is the script that makes the GUI appear with the player and the platform.

local remoteEvent = script.Parent.Parent.ReplicatedStorage.events.PlatformCommand
local PlatformName = script.Parent.Parent.StarterGui.PlatformGUI.ImageLabel.PlatformInput
local name = script.Parent.Parent.StarterGui.PlatformGUI.ImageLabel.PlayerName
local tweenservice = game:GetService("TweenService")

	remoteEvent.OnServerEvent:Connect(function(player, Platform)
	
	
	
		PlatformName.Visible = true
		PlatformName.PlatformInput.Text = Platform 
		name.Text = player.name
end)

image

1 Like

Have you tried using the command to see if it works?
Also, try searching it without the :

This is all that happens

I don’t really know the problem as I’m not that good of a scripter. Sorry.

When I got the error on the server plugin version saying that I needed to use a client plugin I just changed where it said server to client, this is what the server plugin looks like.

--!nolint UnknownGlobal
--[[
	SERVER PLUGINS' NAMES MUST START WITH "Server:" OR "Server-"
	CLIENT PLUGINS' NAMES MUST START WITH "Client:" OR "Client-"
	
	Plugins have full access to the server/client tables and most variables.
	
	You can use the MakePluginEvent to use the script instead of setting up an event.
	PlayerChatted will get chats from the custom chat and nil players. 
	PlayerJoined will fire after the player finishes initial loading
	CharacterAdded will also fire after the player is loaded, it does not use the CharacterAdded event.
	
	service.HookEvent('PlayerChatted',function(msg,plr) 
		print(msg..' from '..plr.Name..' Example Plugin')
	end)
	
	service.HookEvent('PlayerJoined',function(p) 
		print(p.Name..' Joined! Example Plugin') 
	end)
	
	service.HookEvent('CharacterAdded',function(plr) 
		server.RunCommand('name',plr.Name,'BobTest Example Plugin') 
	end)
	
--]]

return function()
	server.Commands.ExampleCommand = {
		Prefix = server.Settings.Prefix;	-- Prefix to use for command
		Commands = {"example"};	-- Commands
		Args = {"arg1"};	-- Command arguments
		Description = "Example command";	-- Command Description
		Hidden = true; -- Is it hidden from the command list?
		Fun = false;	-- Is it fun?
		AdminLevel = "Players";	    -- Admin level; If using settings.CustomRanks set this to the custom rank name (eg. "Baristas")
		Function = function(plr,args)    -- Function to run for command
			print("HELLO WORLD FROM AN EXAMPLE COMMAND :)")
			print("Player supplied args[1] "..tostring(args[1]))
		end
	}
end

The Adonis Client does not handle command storage nor processing, you will need to move the plugin back to the server.

The client does not have a local command system.

So to fix your problem, you will need to do a few changes in order to achieve the goal you wish to reach.

To start out, you will need to have a client remote endpoint that returns the settings you need, such as isMobile, isComputer, and isConsole.

We can do this with a Client Plugin;
Let’s call this plugin Client: GetUserInputSettings

This piece of code adds a new endpoint to the Clients Remote system, allowing the Server to call it and fetch information.

client = nil
service = nil 

return function()
	client.Remote.Returnables.UserInputSettings = function(args)
		local UserInputService = service.UserInputService
		return {
			isMobile = UserInputService.TouchEnabled;
			isComputer = UserInputService.KeyboardEnabled;
			isConsole = UserInputService.GamepadEnabled;
		}
	end
end

On the server side, we can add a command now through a plugin.
Let’s call this plugin Server: PlatformCommand

server = nil
service = nil

return function()
	server.Commands.platform = {
		Prefix = server.Settings.Prefix;	-- Prefix to use for command
		Commands = {"platform"};	-- Commands
		Args = {"player"};	-- Command arguments
		Description = "Says what platform the player is on.";	-- Command Description
		Hidden = false; -- Is it hidden from the command list?
		Fun = false;	-- Is it fun?
		AdminLevel = "Admins";	    -- Admin level; If using settings.CustomRanks set this to the custom rank name (eg. "Baristas")
		Function = function(plr,args)    -- Function to run for command
			-- Get all the players they referenced
			for _,p in pairs(service.GetPlayers(plr, args[1])) do
				-- Get the players PlayerSettings
				local PlayerSettings = server.Remote.Get(p, "UserInputSettings")
				local isMobile, isComputer, isConsole = PlayerSettings.isMobile, PlayerSettings.isComputer, PlayerSettings.isConsole
				
				server.Functions.Hint(
					string.format("%s is on the %s platform!", 
						p.Name, 
							isMobile and "Mobile" or 
							isComputer and "Computer" or 
							isConsole and "Console" or 
							"Unknown"
					), 
					{plr}
				)
			end
		end
	}
end

Reading over your code, it looks like you were intending to create a custom UI to display the Platform on. This code was setting the StarterGui, not the PlayerGui of the player who called the command.

Instead of trying to work around your current structure, I just used the built-in Adonis UI system to create a temporary hint above the player who ran the command for each specific player they want to see.

Cheers!

Thanks, it worked will give you some credit for the help.

2 Likes