Custom command issue (Nexus Admin)

  1. What do you want to achieve? Keep it simple and clear!
    I am trying to make a custom command for Nexus Admin that sets a number/integer value to a value passed by the user.

  2. What is the issue? Include screenshots/videos if possible!
    Every time I try to use the command, the command doesn’t work because the argument is returned as a table instead of just the passed value.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I’ve tried to look for solutions on the dev forum and looked through cmdr and Nexus Admin documentation, but I haven’t found anything for my issue unless I haven’t looked hard enough.

ModuleScript
local SetTemperatureData = {
	Keyword = "SetTemperature",
	Prefix = nexusAdminAPI.Configuration.CommandPrefix,
	Category = "FacilityConfiguration",
	Description = "Sets the core temperature",
	AdminLevel = 2,
	Arguments = {
		{
			Type = "integer",
			Name = "Temperature",
			Description = "Temperature to set the core at",
		},
	},
	Run = function(Temperature)
		game:GetService("ServerStorage").Temperature.Value = Temperature
	end,
}
nexusAdminAPI.Registry:LoadCommand(SetTemperatureData)
return true
Console Output
  12:15:40.293  value of type table cannot be converted to a number  -  Server - SetTemperature:17
  12:15:40.293  Stack Begin  -  Studio
  12:15:40.293  Script 'ServerScriptService.NexusAdminLoader.SetTemperature', Line 17 - function Run  -  Studio - SetTemperature:17
  12:15:40.293  Script 'ServerScriptService.NexusAdmin.Common.Registry', Line 141  -  Studio - Registry:141
  12:15:40.293  Script 'ServerScriptService.NexusAdmin.Cmdr.Shared.Command', Line 156 - function Run  -  Studio - Command:156
  12:15:40.293  Script 'ServerScriptService.NexusAdmin.Cmdr.Shared.Dispatcher', Line 122  -  Studio - Dispatcher:122
  12:15:40.293  Script 'ServerScriptService.NexusAdmin.Cmdr.Shared.Dispatcher', Line 115 - function EvaluateAndRun  -  Studio - Dispatcher:115
  12:15:40.293  Script 'ServerScriptService.NexusAdmin.Cmdr', Line 69  -  Studio - Cmdr:69
  12:15:40.293  Stack End  -  Studio
1 Like

" 12:15:40.293 Script ‘ServerScriptService.NexusAdmin.Cmdr’, Line 69 - Studio - Cmdr:69
12:15:40.293 Stack End - Studio"

Heh, Line 69.
Nice.

Should be pretty obvious, Temperature is a table, not a number. Print out Temperature and see what you get, and make sure you are setting up your command correctly.

Thank you! I fixed it. Seems I needed to do

	Run = function(self, CommandContext, Temperature)
		game.ServerStorage.Temperature.Value = Temperature
	end,

instead of

	Run = function(Temperature)
		game:GetService("ServerStorage").Temperature.Value = Temperature
	end,

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.