Trying to delete a message

My current script is

local Chat = game:GetService("Chat")

game.Players.PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(speaker, recipient, message)
		if string.sub(message, 1, 1) == ":" then
			Chat:RegisterChatCallback("OnServerReceivingMessage", function(message)
				message.ShouldDeliver = false 
				return message
			end)
		end
	end)
end)

Any errors that appear? An error would help to solve this.

invalid argument #1 to ‘sub’ (string expected, got nil)

RegisterChatCallback needs to be made before the Chatted event as the chatted event is called:

local Chat = game:GetService("Chat")
Chat:RegisterChatCallback("OnServerReceivingMessage", function(message)
	if string.sub(message.Message, 1, 1) == ":" then
		message.ShouldDeliver = false 
		return message
	end
end)

Thanks, also do u know how to make it so I can send a message to the layer client sided. (so other people won’t see it. only the person who sent the message)

You can mess around with the In-Experience Text Chat | Roblox Creator Documentation, there are a lot of functions for doing different things.

How do I use this? :confused: :confused:

There are many tutorials however it seems to use ChatService (the same that you’ve been using)

But do they send message client sided?

You can send them to their own channel so they only see their own messages.

Like system?

woresjndsdjnsadfnjsafnjs

Yes, or you can create their own via :AddChannel()

This is all very confusing. I will just stick to the original code. Lol.