Why color is getting nil value when I share it as argument?

this code should change color and do system message when fires remote event, but when I call function to do it color value is getting nil


local TextChatService = game:GetService("TextChatService")

local RBXGeneral = TextChatService.TextChannels.RBXGeneral

local Event = game.ReplicatedStorage:WaitForChild("BadgeTextAplication")

TextChatService.OnIncomingMessage = function(textChatMessage, color)
	if textChatMessage.Metadata then
		if color then
			local textColor = color
			print("Received color:", textColor)

			local overrideProperties = Instance.new("TextChatMessageProperties")
			overrideProperties.Text = string.format("<font color='%s'>%s</font>", textColor, textChatMessage.Text)

			return overrideProperties
			print("Color is nil")
			return nil
		-- do nothing
		return nil

Event.OnClientEvent:Connect(function(plr, diff, color)
	print("Received event:", plr, diff, color) -- Debugging line

	local msg = "GG " .. tostring(plr.Name) .. ", pass " .. diff .. "!"

	RBXGeneral:DisplaySystemMessage(msg, color)

	print("Sent color:", color) 



16:55:52.321 Received event: zuner_floodescape Easy #406c4e - Client - ChatHandler:29
16:55:52.322 Color is nil - Client - ChatHandler:18
16:55:52.323 Sent color: #406c4e - Client - ChatHandler:35

There’s no such parameter specifying the message’s colour. I’m pretty sure it is added in form of a Rich Text to the message itself, but I might be wrong.

1 Like

TextChatService.OnIncomingMessage only has message as parameter, so color will be nil as it’s not sent as a parameter.

1 Like

thanks, is there any method to solve that? (sorry I’m beginner)

I don’t think a message sent by a player can have any other color than white. Can I ask what you are trying to accomplish?

I tryna to do system message that will be visible to the all players, message will greeting player that pass the stage, remote event is called in the script that located in SeverScriptService, and local script in StarterGUI that proceed event, I wanna to make the color that system greeting custom.

If you want to have a standard color for your system message, you can change the first “%s” to the hex code of the color you want. If that doesnt work, I dont know how to do it either, sorry.

okay, thank you for helping, I’ll tryna other way.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.