Rainbow colored chat not working

Hello developers, I’m currently trying to make a rainbow chat for TextChatService that only players whom own a certain gamepass can have. However, its not working. The code is in a local script in StarterCharacterScripts. Here is my code:

--//Services
local GAMEPASS_SERVICE = game:GetService("MarketplaceService")
local TEXT_CHAT_SERVICE = game:GetService("TextChatService")
local RS = game:GetService("RunService")

--//Variables
local player = game.Players.LocalPlayer
local window = TEXT_CHAT_SERVICE:WaitForChild("ChatWindowConfiguration")
local badge_id = 832699871

--//Functions
player.Chatted:Connect(function(message)
		if GAMEPASS_SERVICE:UserOwnsGamePassAsync(player.UserId, 832699871) then
		RS.Heartbeat:Connect(function(delta)
			window.TextColor3 = Color3.fromHSV(tick() % 1, 1, 1)
			task.wait(0.075)
		end)
	end
end)

I have removed the “Player.Chatted” and it works, however, only the person that owns the gamepass can see it. I tried making it in a server script, however that made everyone - even if they don’t own the gamepass - have a rainbow colored chat.

Any help is appreciated :cowboy_hat_face:

1 Like

You need to use RemoteEvent

ServiceScriptService

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")

local gamePassId = 832699871
local gamePassCheckEvent = Instance.new("RemoteEvent", ReplicatedStorage)
gamePassCheckEvent.Name = "GamePassCheck"

Players.PlayerAdded:Connect(function(player)
    local ownsGamePass = false

    -- Check if the player owns the game pass
    local success, result = pcall(function()
        return MarketplaceService:UserOwnsGamePassAsync(player.UserId, gamePassId)
    end)
    
    if success and result then
        ownsGamePass = true
    end

    if ownsGamePass then
        gamePassCheckEvent:FireClient(player, ownsGamePass)
    end
end)

Localscript

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TextChatService = game:GetService("TextChatService")
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")

local player = Players.LocalPlayer
local gamePassCheckEvent = ReplicatedStorage:WaitForChild("GamePassCheck")
local window = TextChatService:WaitForChild("ChatWindowConfiguration")

gamePassCheckEvent.OnClientEvent:Connect(function(ownsGamePass)
    if ownsGamePass then
        RunService.Heartbeat:Connect(function()
            window.DefaultTextColor3 = Color3.fromHSV(tick() % 1, 1, 1)
            task.wait(0.075)
        end)
    end
end)

Please heart this comment if it works.

2 Likes

So it works… Kind of. Funny enough chatgpt showed me the same thing. The problem is, however, even players that dont have VIP also get rainbow chats. If a non-vip talks before a vip, the non-vip’s message is white. When the vip talks, all messages go to rainbow. I’ve tried text labels and it still hasn’t worked yet :sweat_smile:

Client:

--//Services
local GAMEPASS_SERVICE = game:GetService("MarketplaceService")
local TEXT_CHAT_SERVICE = game:GetService("TextChatService")
local RS = game:GetService("RunService")
local REP_STORAGE = game:GetService("ReplicatedStorage")

--//Variables
local player = game.Players.LocalPlayer
local window = TEXT_CHAT_SERVICE:WaitForChild("ChatWindowConfiguration")
local message_event = REP_STORAGE:WaitForChild("EVENTS").GUI_EVENTS.CHAT.MESSAGE_EVENT

--//Update chat color
function update_color(text_label)
	RS.Heartbeat:Connect(function()
		window.TextColor3 = Color3.fromHSV(tick() % 1,1,1)
	end)
end

--//Handle incoming chat messages
function on_message_received(player_name, message, is_vip)
	print("Received message from " .. player_name .. " (VIP: " .. tostring(is_vip) .. "): " .. message)
	
		if (is_vip == true) then
		print("Applying rainbow effect to message from VIP player: " .. player_name)
		update_color()
	end
	
	if (is_vip == false) then
		window.TextColor3 = Color3.new(1,1,1)
	end
	
end

--//Connecting event
message_event.OnClientEvent:Connect(on_message_received)

Server:

--//Services
local GAMEPASS_SERVICE = game:GetService("MarketplaceService")
local TEXT_CHAT_SERVICE = game:GetService("TextChatService")
local PLAYERS = game:GetService("Players")
local RS = game:GetService("ReplicatedStorage")

--//Variables
local pass_id = 832699871
local message_event = RS:WaitForChild("EVENTS").GUI_EVENTS.CHAT.MESSAGE_EVENT

--//Handle player chat
function on_player_chatted(player, message)
	local success, owns_gamepass = pcall(function()
		return GAMEPASS_SERVICE:UserOwnsGamePassAsync(player.UserId, pass_id)
		
	end)
		
	if success then
		print(player.Name .. " owns gamepass: " .. tostring(owns_gamepass))
		
		message_event:FireAllClients(player.Name, message, owns_gamepass)
	else
		warn("Failed to check ownership for player: ".. player.Name)
	end
end

--//Connect player chat
PLAYERS.PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(message)
		on_player_chatted(player, message)
	end)
end)

Any help is appreciated :cowboy_hat_face:

So I’ve kind of just came to a conclusion with the current TextChatService I do not feel its possible to create what I’m looking for without making a whole new chat system. I’m just going to have the rainbow chat be client only. However, I wont mark anything as a solution in case someone wants to chime in with their ideas/opinion.

It is possible, I don’t know WHAT you WANT to do.

1 Like

Ah, sorry. Basically, I want to make it so the people that own the VIP gamepass have a rainbow chat window color that all players can see. However the issue is it either only works client side, or the whole server just also gets a rainbow chat even if they dont own the gamepass