The following code is supposed to check if a message starts with “:” then if it does, delete the message.
local module = require(game.Chat.ChatScript.ChatMain.ChatChannel)
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(speaker, recipient, message)
if string.sub(message, 1, 1) == ":" then
module.methods:RemoveMessage(message)
end
end)
end)
It currently gives the error
invalid argument #1 to 'sub' (string expected, got nil)
There’s an error with the module, whereas the code above is working fine. I’m assuming you don’t want the message to be delivered, therefore, you could use