#Need Help - Error calling TextChatService.OnBubbleAdded: TextColor is not a valid member of Color3

1 messages · Page 1 of 1 (latest)

ashen zenith
#

I'm making a GUI where the player can change their bubble text colour and bubble background colour.
Upon clicking a button, either the text or bubble colour can be changed, and the text displays in its new colour, and is saved to the server in a customPlayerChat table, in either a BackgroundColor or TextColor field for the player who changed it.

However, even if no colours are changed via the GUI, the error: Error occurred while calling TextChatService.OnBubbleAdded: TextColor is not a valid member of Color3 -- Client appears, and the bubble doesn't show up above the player's head UNTIL either the text colour or the bubble colour have been changed using the GUI.

Here's the client script where I think the problem is coming from. Does anyone know what could be causing this?

TextChatService.OnBubbleAdded = function(message: TextChatMessage, adornee: Instance)
    if message.TextSource then
        
        local player = Players:GetPlayerByUserId(message.TextSource.UserId)
        local customPlayerChat = getTextColourEvent:InvokeServer(player) or Color3.fromRGB(57, 59, 61) -- Get the player's colour or grey if player has no custom color
        local chatCol = customPlayerChat and customPlayerChat.TextColor or Color3.fromRGB(57, 59, 61)  -- Default to grey if nil
        local bubbleProperties = Instance.new("BubbleChatMessageProperties")
        
        
        bubbleProperties.TextColor3 = chatCol
        
        local customPlayerChat = getBubbleColourEvent:InvokeServer(player) or Color3.fromRGB(250, 250, 250)
        local bubbleCol = customPlayerChat and customPlayerChat.BackgroundColor or Color3.fromRGB(250, 250, 250)

        print("Received background colour: ", bubbleCol)
        bubbleProperties.BackgroundColor3 = bubbleCol
        return bubbleProperties
    end
end
ashen zenith
#

Need Help - Error calling TextChatService.OnBubbleAdded: TextColor is not a valid member of Color3

steady canyon
#

this is what TextColor is supposed to be btw

#

Whilist TextColor3 is

ashen zenith
#

TextColor is the name of the field in the table

#

Even after changing the variable to TextCol, it still happens

steady canyon
#

Have you printed out whats inside TextColor?

ashen zenith
# ashen zenith Even after changing the variable to `TextCol`, it still happens

I've tried to print it when the bubble is added, but I get this same error as before.

TextChatService.OnBubbleAdded = function(message: TextChatMessage, adornee: Instance)
    if message.TextSource then
        
        local player = Players:GetPlayerByUserId(message.TextSource.UserId)
        local customPlayerChat = getTextColourEvent:InvokeServer(player) or Color3.fromRGB(57, 59, 61) -- we get the player's color or WHITE if player has no custom color
        local chatCol = customPlayerChat and customPlayerChat.TextCol or Color3.fromRGB(57, 59, 61)  -- Default to gray if nil
        local bubbleProperties = Instance.new("BubbleChatMessageProperties")
        print(chatCol)
ashen zenith
#

I'm gonna assume that it is nil at the start, because if I edit this line:

local chatCol = customPlayerChat and customPlayerChat.TextCol or Color3.fromRGB(57, 59, 61)  -- Default to gray if nil`

and change it to

local chatCol = Color3.fromRGB(57, 59, 61)  -- Default to gray if nil

Then things work normally.

#

What I'm assuming is

  • The TextCol field of the customPlayerChat is nil (nothing inside it)
  • It's trying to assign a blank value and display it.