Message Prefix goes onto the next message

Example: You have 2 players chatting, and the 1st player has a nametag that says owner. If the 2nd player makes their message after that 1st player, their message will have the owner nametag too, AND their name in the chat will be the 1st player’s name.

Code:

local Properties = Instance.new('TextChatMessageProperties')


local tags = {
	[150] = {TagText = "[Playtester]", TagColor = {255,255,0}},
	[175] = {TagText = "[Admin]", TagColor = {0,0,255}},
	[255] = {TagText = "[Owner]", TagColor = {200, 0, 0}},

}
TextChatService.OnIncomingMessage = (function(Message: TextChatMessage)
	
	if Message.TextSource then
		local player = game.Players:GetPlayerByUserId(Message.TextSource.UserId)
		if player:IsInGroup(17246086) then 
			for i,v in pairs(tags) do
				if player:GetRankInGroup(17246086) >= i then
					Properties.PrefixText = "<font color='rgb(" .. v.TagColor[1] .. "," .. v.TagColor[2] .. "," .. v.TagColor[3] .. ")'>" .. v.TagText .. " </font>" .. Message.PrefixText

				end
			end
		end

	else
		Properties.PrefixText = Message.PrefixText
	end
	
	return Properties

end)

Wait you want this to happen or don’t want?

I still want the message prefixes to work, but I dont want it where the next player gets the previous player’s prefix

I noticed that you are not breaking the for loop, making it stack instead. Try fixing that, maybe it’s a text issue of the chat box itself.

nah its not the for loop cuz i tested

Ah, the problem is that you are not creating a new TextChatMessageProperties everytime someone chats. When the properties gets updated to be the owner tag, the next non-group member message will still have the owner properties.

oh i see, ill try that thanks and see if it works

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