I’m trying to figure out a way to modify the chatbox so that…
- Create a ‘bot’ that sends automated messages every three minutes or so
- Change the chat color of certain users (specifically higher ranked users)
I figured that I should create a folder in the Chat service named “ChatModules”, with a ModuleScript inside of it. However whenever I do that, it overrides the basic chat system and player names are the default rather than their TeamColor. Furthermore, the chat stops updating if you rejoin, and chat bubbles don’t show.
Is there a way to just modify the current behavior? Or is there a ModuleScript out there that replicates the current effects so I can just modify that?
For the automated messages, you can use Documentation - Roblox Creator Hub
Specifically, “ChatMakeSystemMessage”.
game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage",
Text = "hello";
Color = Color3.new(0,0,0))
7 Likes
You should be able to create a new ModuleScript in the ChatModules, following the wiki’s guide on making custom features in the chat.
return function(ChatService)
-- code
end
Create a new chat speaker (ChatService:AddSpeaker()
), then have it send messages however you like.
There is no need to completely clear all of the chat modules, since that would obviously break the chat.
1 Like
Continuing off of what @EmeraldSlash said:
If you do not already have the default Chat modules and other scripts, you can easily get them by running a local server test, copying the contents of the Chat service, and pasting them into the Chat service of your game.
Once you do this, follow EmeraldSlash’s advice in creating a module.
Feel free to PM me if you need any more assistance. I recently wrote a chat module for a loot announcement system in my game.
3 Likes
Okay, so that was my main problem, all I had was a ChatModules folder with the one custom ModuleScript inside of it. However, while player name colors are now loaded correctly based on their teams, it seems the entire system still breaks when you rejoin the server. That is, the chat will update when you first join, but new chat messages won’t be displayed afterwards (including your own).
See what I mean here:
https://gyazo.com/28742d261b596ba7c026362576b72e8f
Were there any errors when you left and/or rejoined?
Nope, no errors. However, after talking it over with a friend, I realized the problem was how I implemented the notification bot. I had it in an infinite loop with a delay of 180 seconds between messages. I didn’t realize this was a problem until I remembered it was returning a function that was probably run right away…which in turn meant that the chat script wouldn’t resume. No idea why this was only a problem when a player rejoined, but whatever.
All I did to solve the problem was make the loop another thread using spawn(). There might have been a better way, but oh well.
(I really should get a rubber duck to talk these things through with)
Great! Glad you got it working!
1 Like