A lot of the time when I make commands specific to my games, I resort to chat commands as they are the quickest to script. Because of this, I decided to check out Roblox’s chat system’s ability to register commands, though I’m having no luck getting it to actually work.
I’m trying to register a command using one of my scripts, and the command does something internally that requires the function to be inside the script it effects. So, I made the script register the function with Roblox’s chat.
The issue is that the function doesn’t seem to run at all. There’s no error when I register it, and when I do a check through the ChatService module, it says it’s registered. Trying to register it a second time with the same id errors, as it should. Therefore, the function has been registered yet still won’t run no matter what I chat.
I’ve looked at the wiki on how they do it, and the only thing they do different is that they register the function using a module script inside the chat modules folder. Though as far as I can tell, having a module there is just for convenience, and shouldn’t actually make a difference. Also, as I said earlier, the function the command uses needs to be inside a different script, so putting it inside a module in the chat modules folder isn’t an option.
To show an example of it not working, I made this example script:
local function TestFunction()
print("Why doesn't this work?")
return true
end
local ChatService = require(game:GetService("Chat"):WaitForChild("ChatServiceRunner"):WaitForChild("ChatService"))
ChatService:RegisterProcessCommandsFunction("TestFunction", TestFunction)
Why doesn’t this work?