How to make chat bot

im not familiar with chatservice at all or the new textchat service. I’d like to make a chat bot that will send a message into the chat so that all players can see said message, ive looked at some documentation but im still pretty confused on what to do or where to start. An explamation would really help!!! (im not really asking for code)

thank you for your time

2 Likes

Alright. Chatbots require input and output. If input is player chatting in built-in chat, then you need to use Player.Chatted event for this. Output however it not as simple. I think this thread should provide enough info on how to script a chatted message (in default Roblox chat).

1 Like

Its a bit unclear what you are looking for but what I am gathering is that you want to make a system message show in the chat of all players?

The way I do this is I make a RemoteEvent on the client that makes the message, and then run remote:FireAllClients("message here") and it shows for everyone.

1 Like

If you want to create an actual speaker (an entity that typically represents a user but isn’t restricted to representing a user), you can use ChatService:AddSpeaker() (the one that’s replicated under ServerScriptService) to create a new speaker, controlled by the server like so:

local chatService = require(script.Parent:WaitForChild('ChatServiceRunner'):WaitForChild('ChatService'))

task.wait(10)

local speaker = chatService:AddSpeaker('Chat bot')
speaker:JoinChannel('All')
speaker:SayMessage('Hey!', 'All')

image

Much like a player, you can also make this bot have tags like this:

speaker:SayMessage('Hey!', 'All', {
	-- here is where the extra data (like chat tags and chat colour) go
	Tags = {
		{
			-- you can also add multiple tags like so
			TagText = 'Bot';
			TagColor = Color3.new(1,1,0);
		};
		{
			TagText = 'Cool';
			TagColor = Color3.new(1,0,0);
		}
	};
	ChatColor = Color3.new(0.5,0.5,0.5);
	NameColor = Color3.new(1,0,1)
})

image
Or, you can assign extra data to the speaker like so:

speaker:SetExtraData('Tags', {
		{
			TagText = 'Bot';
			TagColor = Color3.new(1,1,0);
		};
		{
			TagText = 'Cool';
			TagColor = Color3.new(1,0,0);
		}
	}
)
speaker:SetExtraData('ChatColor', Color3.new(0.5,0.5,0.5))
speaker:SetExtraData('NameColor', Color3.new(1,0,1))

image

5 Likes

thank you! this really helped me alot!!

i have a few questions tho,

will the script automatically recodnize these and assign the data? can the chatcolors and textcolor variables be named anything?

will this script work on both client and server?

Those are table indexes, not variables.

No, server only.

1 Like