Ok so me and my friend made a custom chat system but the thing is our / commands are kinda broken. I need some help fixing this. What it do is if I do anything like /stats it react as if i’m putting /s (/s is shouting) Or if I do /list it reacts as if i’m trying to do /l (/low)
– // FileName: MeCommand.lua
– // Written by: TheGamer101
– // Description: Sets the type of /me messages.
local Chat = game:GetService(“Chat”)
local ReplicatedModules = Chat:WaitForChild(“ClientChatModules”)
local ChatConstants = require(ReplicatedModules:WaitForChild(“ChatConstants”))
local ChatSettings = require(ReplicatedModules:WaitForChild(“ChatSettings”))
local function Run(ChatService)
if ChatSettings and true then
local function MeCommandFilterFunction(speakerName, messageObj, channelName)
local message = messageObj.Message
if message and string.sub(message, 1, 4):lower() == "/do " then
-- Set a different message type so that clients can render the message differently.
messageObj.MessageType = ChatConstants.MessageTypeMeCommand
end
end
ChatService:RegisterFilterMessageFunction("do_command", MeCommandFilterFunction)
end
Looks like you’re depending on more ModuleScripts. I don’t see the logic where /list would be accepted as /l instead of /list. Is it possible to share some more of the code you’re depending on? I’m concerned about the if ChatSettings and true then in your Run function - the and true is completely redundant (possibly a temporary debug solution?).
Usually for custom chat commands, something like this is an efficient and easily scalable method - utilizing string.split() to arrange each argument of the Chat message into separate parts, e.g. 1) a command prefix, 2) command name, 3) optional command arguments.