Rainbow chat applying color to the wrong people

hey there my dear robloxians, I’ve been trying to fix this for over a week now.
i have a gamepass that makes your name color in chat color rainbow.

sometimes this applies to the wrong name tag. but the loop never gets fired.
Does anyone know how to fix this issue?

the defaulthchatmessage script is what I’ve edited to make the name color change
image
I’ve already tried to debug this but it has lead me to nothing.
i don’t know why this loop is being added to the other name colors since it cant even pass the if statement

spawn(function()
		if game.Players:FindFirstChild(fromSpeaker).PlayerData.HasRainbowChat.Value then
			local Button = NameButton
			local Name = fromSpeaker
			while true do
				T:Create(Button,TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut),{TextColor3 = Color3.fromRGB(255, 97, 100)}):Play()
				wait(1)
				T:Create(Button,TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut),{TextColor3 = Color3.fromRGB(184, 97, 255)}):Play()
				wait(1)
				T:Create(Button,TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut),{TextColor3 = Color3.fromRGB(99, 180, 255)}):Play()
				wait(1)
				T:Create(Button,TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut),{TextColor3 = Color3.fromRGB(103, 255, 101)}):Play()
				wait(1)
				T:Create(Button,TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut),{TextColor3 = Color3.fromRGB(255, 198, 98)}):Play()
				wait(1)
			end
		end
	end)

would love to hear what you guys think what could be wrong with it. since i am not quite sure if its my code or the chat script.

Do any errors pop up at all in the output?

no, since it works but aswell not works.

What is “fromSpeaker” and “NameButton”? Provide the whole snippet that is relevant.

Why not use the ExtraDataInitializer module to determine whether a speaker has rainbow chat or not? I don’t really see the point in having a ValueObject when the Lua Chat System provides you with a method for storing data for speakers.

as i said in my post its basicly the defaulthchatmessage script with these lines added.

i just wanted to test this out and see if it worked.

That’s not enough information to go off of, which is why I asked what values are assigned to those variables in the first place. Just post the lines to make it easier for me to suggest potential fixes.

from speaker is the Username as you can see in my script. Name button is the Name displayed in chat where you can click on an user to whisper.

all i am doing is checking if the user with the username has thier value set to true.

and theres no direct indication of why this is happening

No, I can’t see that in your script, because you still haven’t provided me the explicit line of code that shows what “fromSpeaker” is.

In general, have you actually even tried debugging your script first before posting? Throw prints around and see what’s being printed from your variable assignments, as well as which prints run and what don’t.

FROMSPEAKER Is an varible inside Chatmakemessage that it gets received once the make message function has been fired. each time you talk in chat the function that roblox made is getting fired.
it recieves the Username that is FROMSPEAKER i am using this varible to check in game.players if they have it or not.

and yes i’ve been debugging this out for a while now. and it seems my code works fine. and it looks like roblox thier code is messed up.

Just tried a repro in Studio and got it to work. I moved this code over to the Util module instead and had the loop run upon the creation of the name button. I can’t confirm the ability of it to work outside of standardised/global chats though.

image

function methods:AddNameButtonToBaseMessage(BaseMessage, nameColor, formatName, playerName)
	local speakerNameSize = self:GetStringTextBounds(formatName, BaseMessage.Font, BaseMessage.TextSize)
	local NameButton = self:GetFromObjectPool("TextButton")
	NameButton.Selectable = false
	NameButton.Size = UDim2.new(0, speakerNameSize.X, 0, speakerNameSize.Y)
	NameButton.Position = UDim2.new(0, 0, 0, 0)
	NameButton.BackgroundTransparency = 1
	NameButton.Font = BaseMessage.Font
	NameButton.TextSize = BaseMessage.TextSize
	NameButton.TextXAlignment = BaseMessage.TextXAlignment
	NameButton.TextYAlignment = BaseMessage.TextYAlignment
	NameButton.TextTransparency = BaseMessage.TextTransparency
	NameButton.TextStrokeTransparency = BaseMessage.TextStrokeTransparency
	NameButton.TextColor3 = nameColor
	NameButton.Text = formatName
	NameButton.Visible = true
	NameButton.Parent = BaseMessage

	local clickedConn = NameButton.MouseButton1Click:connect(function()
		self:NameButtonClicked(NameButton, playerName)
	end)

	local changedConn = nil
	changedConn = NameButton.Changed:connect(function(prop)
		if prop == "Parent" then
			clickedConn:Disconnect()
			changedConn:Disconnect()
		end
	end)
	
	spawn(function ()
		local T = game:GetService("TweenService")
		while true do
			T:Create(NameButton,TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut),{TextColor3 = Color3.fromRGB(255, 97, 100)}):Play()
			wait(1)
			T:Create(NameButton,TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut),{TextColor3 = Color3.fromRGB(184, 97, 255)}):Play()
			wait(1)
			T:Create(NameButton,TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut),{TextColor3 = Color3.fromRGB(99, 180, 255)}):Play()
			wait(1)
			T:Create(NameButton,TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut),{TextColor3 = Color3.fromRGB(103, 255, 101)}):Play()
			wait(1)
			T:Create(NameButton,TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut),{TextColor3 = Color3.fromRGB(255, 198, 98)}):Play()
			wait(1)
		end
	end)

	return NameButton
end

You will of course be responsible for modifying this to suit your needs, but this should work. Go ahead and give it a try.

1 Like

it looks fine with the first few messages. go throw this on a test place and try it out. for example give 3 people the rainbow chat and the rest the regular chat. after while you see people without it getting their names in a rainbow. and then after they speak a few messages its going back to normal

I honestly don’t understand how you’re going about the implementation. This is not happening for me.

image

NameButton in the Util function returns a TextButton object. The loop runs on that very TextButton.

image looks here they all have the rainbow chat. but what my issue is if you read my post correctly. Sometimes People without the chat pass still gets the rainbow color. and thats not what its suppose to do.

try to use this inside player instead of studio since in-studio it worked as well fine for me but not in player.
Roblox studio isn’t the best at replicating an real roblox server

Yes. I read your post correctly. I explicitly gave you instructions on my repro regarding the usage of it. It is merely a guideline and a suggestion. I’m not going to spoonfeed you code.

for you information your tactic doesnt work iether. like i said. this time its only locally image

Strange. I’ll see if I can devise another repro, unless someone tackles this before me.

here are the files. repro.rbxm (19.2 KB) so you can replicate this.

I took your repro file and tested it. The only was I was able to replicate the issue was with this line.

 if game.Players:FindFirstChild(playerName).PlayerData.HasRainbowChat.Value then

The script is looking for a child that either:
1. Has a property called Value
2. Has a child called Value.

Now if either of these returns true. That person will be given rainbow chat. Now however for me. If HasRainbowChat is a BoolValue, and it’s value is set to true. The person will be given Rainbow chat. While if the value is set to false the person won’t be given it.
If HasRainbowChat is a StringValue, NumberValue or anything else that has a property called ‘Value’. The player will be given Rainbow chat. Regardless of what the ‘value’ of that property is.
This was the only way I could reproduce you’re issue as described in the OP.

3 Likes