How to change the text color of specific speech bubbles

"I’m looking for a way to change the text color of bubble chat when a player enters a specific message. I’m struggling because I can’t find a way to change only the color of the text containing certain messages, not the text color of multiple bubble chats. In the game ‘Mortem Metallum[Alpha],’ the message color turns red if the message ends with ‘!’.

I want to change the text color to yellow when the message ends with ‘?’. If anyone knows how to achieve this, please share the script. Thank you! Please note that I’m using a translator, so my English might sound awkward."

2 Likes
local QuestionMarkMatch = string.match(message, "?")
local ExclamationMarkMatch = string.match(message, "!")
if QuestionMarkMatch then
   -- Change bubble chat colour to yellow
elseif ExclamationMarkMatch then
   -- Change bubble chat colour to red
end

If a message has both an exclamation and question mark it will be yellow because of the order of the commands. If you want to do something else if it has both then just change it to something like that:

local QuestionMarkMatch = string.match(message, "?")
local ExclamationMarkMatch = string.match(message, "!")
if QuestionMarkMatch and ExclamationMarkMatch then
   -- Change bubble chat colour somthing else
elseif QuestionMarkMatch then
   -- Change bubble chat colour to yellow
elseif ExclamationMarkMatch then
   -- Change bubble chat colour to red
end

If you don’t know how to change bubble chat colours then I suggest you watch this video: