Globalchat issue (EXTRA LETTERS)

Hi, so my text wont appear in chat could someone help? I think its a issue with the new chat system I’m not sure also no errors in output.

Script:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local TextService = game:GetService("TextService")
local MessagingService = game:GetService("MessagingService")

local RemotesFolder = ReplicatedStorage:WaitForChild("RemotesFolder")
local MessageEvent = RemotesFolder:WaitForChild("MessageEvent")

local function Color3toString(Color)
	return string.format("rgb(%d, %d, %d)", Color.R * 255, Color.G * 255, Color.B * 255)
end

MessageEvent.OnServerEvent:Connect(function(Player, InfoTable)
	MessagingService:PublishAsync("GlobalChat", {
		InfoTable[1],
		InfoTable[2],
		Color3toString(InfoTable[3]),
		Player.UserId
	})
end)

MessagingService:SubscribeAsync("GlobalChat", function(ReceivedData)
	if ReceivedData then
		local InfoTable = ReceivedData.Data
		local Player = Players:GetPlayerByUserId(InfoTable[4])
		
		for i, LoopedPlayer in pairs(Players:GetPlayers()) do
			local FilteredString, Obj = pcall(function()
				return TextService:FilterStringAsync(
					`{Player.Name} Just Got <font color="{InfoTable[3]}">{InfoTable[1]}</font> Which Has A Chance Of <font color="{InfoTable[3]}">1 in {InfoTable[2]}</font>`,
					Player.UserId,
					Enum.TextFilterContext.PublicChat
				)
			end)
			
			if not FilteredString then return end
			
			local FilterSuccess, Result = pcall(function()
				return Obj:GetChatForUserAsync(LoopedPlayer.UserId)
			end)
			
			if FilterSuccess then
				MessageEvent:FireClient(LoopedPlayer, Result)
			end
		end
	end
end)

ModuleScript:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemotesFolder = ReplicatedStorage:WaitForChild("RemotesFolder")
local MessageEvent = RemotesFolder:WaitForChild("MessageEvent")

local TweenService = game:GetService("TweenService")
local TInfo = TweenInfo.new(.2, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
local TInfo2 = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)

local ClickSound = script:WaitForChild("Click")

local function AnimateRarityText(TextLabel : TextLabel, TextLabel2: TextLabel, RolledTable)
	TextLabel.Position = UDim2.fromScale(.5, .45)
	TextLabel.TextColor3 = RolledTable[3]
	TextLabel.Text = RolledTable[1]
	TextLabel2.Text = `1 in {RolledTable[2]} Chance`
	
	ClickSound:Play()
	TweenService:Create(TextLabel, TInfo, { Position = UDim2.fromScale(.5, .5) }):Play()
	wait(.2)
end

local function LegendaryAnimation(AnimationItems: Frame)
	local RadialGradient = AnimationItems:WaitForChild("RadialGradient")
	local Star = AnimationItems:WaitForChild("Star")
	
	AnimationItems.Visible = true
	Star.Visible = true
	RadialGradient.Visible = true
	Star.Size = UDim2.fromOffset(350, 350)
	Star.ImageTransparency = 1
	Star.Rotation = 8
	RadialGradient.Size = UDim2.fromScale(3, 3)
	
	TweenService:Create(Star, TweenInfo.new(10, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), {
		Rotation = 1700,
		ImageTransparency = 0,
		Size = UDim2.fromOffset(450, 450)
	}):Play()
	
	wait(6)
	
	TweenService:Create(RadialGradient, TweenInfo.new(2, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), {
		Size = UDim2.fromScale(1.5, 1.5)
	}):Play()
	
	wait(1.7)
	
	AnimationItems.Visible = false
end

local function RareAnimation(AnimationItems: Frame)
	local RadialGradient = AnimationItems:WaitForChild("RadialGradient")
	local Star = AnimationItems:WaitForChild("Star")

	AnimationItems.Visible = true
	Star.Visible = false
	RadialGradient.Size = UDim2.fromScale(3, 3)

	TweenService:Create(RadialGradient, TweenInfo.new(5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), {
		Size = UDim2.fromScale(1.5, 1.5)
	}):Play()

	wait(4.5)

	AnimationItems.Visible = false
end

return {
	AnimateRolling = function(AnimationFolder: Frame, AnimationItems: Frame, RolledTable, AnimationSkip)
		local Background : Frame = AnimationFolder:WaitForChild("Background")
		local Rarity : TextLabel = AnimationFolder:WaitForChild("Rarity")
		local Chances : TextLabel = Rarity:WaitForChild("Chances")
		
		AnimationFolder.Visible = true
		
		if AnimationSkip == false then
			for i, CurrentTable in ipairs(RolledTable) do
				if CurrentTable[5] == "RareAnimation" and i == 8 then
					MessageEvent:FireServer(CurrentTable)
					RareAnimation(AnimationItems)
					AnimateRarityText(Rarity, Chances, CurrentTable)
				elseif CurrentTable[5] == "LegendaryAnimation" and i == 8 then 
					MessageEvent:FireServer(CurrentTable)
					LegendaryAnimation(AnimationItems)
					AnimateRarityText(Rarity, Chances, CurrentTable) 
				else
					AnimateRarityText(Rarity, Chances, CurrentTable)
				end
			end
		else
			AnimateRarityText(Rarity, Chances, RolledTable[8])
		end
	end,
	
	AnimateRollButton = function(TextButton: TextButton)
		local AnimationFrame = TextButton.AnimationFrame
		AnimationFrame.Size = UDim2.fromScale(1, 1)
		
		TweenService:Create(AnimationFrame, TInfo2, { Size = UDim2.new(0, 0, 1, 0) }):Play()
	end,
}

You have various problems regarding outdated and improper use of functions.

Some examples include:
I notice that in the SubscribeAsync() block, you get a Player object using Players:GetPlayerByUserId(). However, this returns nil if the player does not exist in the server. What you should use is Players:GetNameFromUserIdAsync() or send the player’s name in the InfoTable.

Do note that these functions below are deprecated in favour of TextChatService and should NOT be used:

Also, according to documentation, TextService:FilterStringAsync() will throw an error if the fromUserId argument has no corresponding player in-game. To solve this, you should filter the string not under :SubscribeAsync() but under :PublishAsync() instead.

A very important note is that TextFilterResult:GetChatForUserAsync() (in your case: Obj:GetChatForUserAsync()) is completely deprecated in favour of filtering through the use of TextChatService. It will always return an empty string.

Important note: the reason you do not see any errors in the output is likely due to the pcalls you have set in place.

PS: There is no reason to filter the text you do in this case, as there is nothing the players can necessarily do to modify what text is sent.

Relevant Documentation:
TextChatService
TextFilterResult:GetChatForUserAsync()
Migration to TextChatService
TextService:FilterStringAsync()
Players:GetPlayerByUserId()
Players:GetNameFromUserIdAsync()

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