It’s not a magic spell or anything involving math.
(@visvisjes All this piece of code does is change the chat type - it does not toggle bubble chat)
Bubble chat is controlled by a LocalScript called BubbleChat which is responsible for drawing the bubble chat UIs above player’s heads. There’s an even better way to do this though without forking; it’ll prevent a sent message from showing up both in bubble chat and in the chat window. The Lua Chat System provides a lot of API so you can modify and extend vanilla chat.
If you’re on Roblox, you should be familiar with the /e dance
chat command. It does not show up on either the chat window or as a chat bubble. This makes use of a command processor (available in documentation as Command Modules). Essentially, what we want to do is stop our message from being processed if the radio is on.
First off, we will need a way to indicate that a player’s radio is on - doesn’t matter how. We will then want to create a Command Module that will stop messages from being processed and sent when typed if radios are on. To add a command module without forking anything else:
- Create a Folder in Chat called ChatModules.
- Insert a BoolValue named InsertDefaultModules and make sure the value is checked off.
- Insert a ModuleScript and give it a fancy name, like RadioChatBlock.
In this ModuleScript, clear out the template code and replace it with the command module boilerplate:
local function Run(ChatService)
local function processChat(speakerName, message, channelName)
return (RADIO_IS_ON_CONDITION)
end
ChatService:RegisterProcessCommandsFunction("RadioChatBlock", processChat)
end
return Run
In RADIO_IS_ON_CONDITION, replace this with the place where you identify whether the radio is on or not, like the value of a BoolValue named On in the radio. If the function returns true when the command is ran, the chat will not be processed and thus will not show up in the chat window or as a bubble chat. If it’s false, the chat will show up.
Thus, there you have it. No chats while the radio’s on!