Chat tag system with attribute isn't working properly

Basically my attempt was to make a chat tag system that allows us to change the player tag at real time or add one more tag to the player.

My expectation was to have the script to add a player chat tag by receiving the attribute inside the player.

But as you can see in the video below, it didn’t go that well, the script event ran 2 times and nothing happened so far. Is there any help to this following issue?

local message = "Welcome "..'<font color="#58e809">'..game.Players.LocalPlayer.DisplayName..'</font>'.."! Have a great game!"
local prefix = "[Server]: "
local TextChatService = game:GetService("TextChatService")

task.wait(2)
TextChatService.TextChannels.RBXGeneral:DisplaySystemMessage(prefix..message)

local RemoteEvent = game.ReplicatedStorage:WaitForChild("RemoteEvents"):WaitForChild("SendChatMessage").OnClientEvent:Connect(function(messageData)
	if messageData then
		local message = messageData.Message
		local prefix = messageData.Prefix
		TextChatService.TextChannels.RBXGeneral:DisplaySystemMessage(prefix..message)
	end
end)

TextChatService.OnIncomingMessage = function(message:TextChatMessage)
	local propertys = Instance.new("TextChatMessageProperties")

	if message.TextSource then
		local player = game.Players:GetPlayerByUserId(message.TextSource.UserId)
		
		player = game.Players:FindFirstChild(player.Name)
		
		if player and player:GetAttribute("Tags") then
			print("should work")
			
			local tags = player:GetAttribute("Tags")
			if tags and tags ~= "" then
				propertys.PrefixText = tags..message.PrefixText
			end
		end
	end
end

I hope i put enough details on what i attempted and what should the script does.

Do you return the new message?

TextChatService.OnIncomingMessage = function(message:TextChatMessage)
	local propertys = Instance.new("TextChatMessageProperties")

	if message.TextSource then
		local player = game.Players:GetPlayerByUserId(message.TextSource.UserId)
		
		player = game.Players:FindFirstChild(player.Name)
		
		if player and player:GetAttribute("Tags") then
			print("should work")
			
			local tags = player:GetAttribute("Tags")
			if tags and tags ~= "" then
				propertys.PrefixText = tags..message.PrefixText
			end
		end
	end
	
	return propertys
end

My bad i forgot, thanks you for your help

No worries, glad I could help :ok_hand:

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