Error occurred while calling TextChatService.OnIncomingMessage: Script that implemented this callback has been destroyed while calling async callback

Hello! So, I getting this error after my script works and I type something in the chat.

here is the script:



local function OnIncomingMessage(msg)
	
	local function Changed()

		if stage.Value == 15 then

			color = "#ffffff"

		elseif stage.Value == 25 then

			color = "#71d400"

		elseif stage.Value == 40 then

			color = "#4b974b"
			
		else
			
			color = "#ffffff"
		end

	end
	
	Changed()
	
	TextChatService.OnIncomingMessage = function(textChatMessage)
		if system == true then

			color = "#ffee00"
			
			if textChatMessage.Metadata 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)

				color = "#ffffff"
				system = false

				return overrideProperties
			else
				-- do nothing
				return nil
			end
			
		else
			
			if textChatMessage.Metadata then
				local textColor = color

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

				color = "#ffffff"

				return overrideProperties
			else
				-- do nothing
				return nil
			end
			
		end
		
	end
	
	RBXGeneral:DisplaySystemMessage(msg)
end

how do I fix it?

where did you parent your script

in the folder “starter GUI”. I think this information be helpful.

move it to ReplicatedFirst instead

I got an error… TextChannels is not a valid member of TextChatService “TextChatService”

local TextChannels=TextChatService:WaitForChild("TextChannels")

THANK YOU VERY MUCH!!! now one more thing, how do I fix transparent stroke?
image

I dont know about that

did you change something in BubbleChatConfiguration? (its parented under TextChatService)

already fix it, THANK YOU VERY MUCH!!!

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