Chat tag not working

repeat
	task.wait()
until game:GetService("Players").LocalPlayer:FindFirstChild("DataLoaded") and game:GetService("Players").LocalPlayer:FindFirstChild("DataLoaded").Value == true


local Players = game:GetService("Players")
local TextChatService = game:GetService("TextChatService")
local PlayersService = game:GetService("Players")


local function hasGamePass(player, gamePassId)
	local success, hasPass = pcall(function()
		return player:HasPass(gamePassId)
	end)
	return success and hasPass
end

local function getTagText(player)
	local tags = {}

	if player.UserId == 1189853533 then
		table.insert(tags, "<font color='#FFFF00' font='Fredoka One'>[🧾 OWNER!]</font>")
	end

	
	return table.concat(tags, " ")
end

local function onIncomingMessage(msg: TextChatMessage)
	local p = Instance.new("TextChatMessageProperties")
	if msg.TextSource then
		local player = Players:GetPlayerByUserId(msg.TextSource.UserId)
		if player then
			local tagText = getTagText(player)
			p.PrefixText = tagText .. " " .. msg.PrefixText
		end
	end
	return p
end

TextChatService.OnIncomingMessage = onIncomingMessage

Hello! I’ve worked on a system that should display [Owner] before name in chat like “[Owner] Vika: Hello!”, this doesn’t work though.

It’s a localscript placed in starterplayerscripts. It worked for me before IN ANOTHER GAME FILE but copied and pasted into another file to use it on a new game. doesnt work on the new one though…

1 Like

Just to confirm:

  • Is the chat version set to Legacy or to the new one?
  • Is the onIncomingMessage function firing?