Rainbow Nametag In The Chat

Hi there! I currently have a nametag system in-game where if you buy the Rainbow Nametag gamepass your name goes rainbow. I was wondering if you can make a script so if you buy a gamepass it make the name in the chat rainbow?

Thank You!

1 Like


Please help this user with there original post.

Sure thing! Here’s a script you can use to change the color of a player’s name in the chat to rainbow when they purchase the Rainbow Nametag gamepass:

-- Change "Rainbow Nametag" to the name of your gamepass
local RAINBOW_COLOR = Color3.fromRGB(255, 0, 0) -- Change this to the color you want

        if gamepassId == GAMEPASS_ID then
                local playerName = player.Name
                local rainbowName = ""
                for i = 1, #playerName do
                    local char = string.sub(playerName, i, i)
                    local r, g, b = math.random(0, 255), math.random(0, 255), math.random(0, 255)
                    local rainbowColor = Color3.fromRGB(r, g, b)
                    rainbowName = rainbowName .. string.format("[%s]%s", tostring(rainbowColor), char)
                game.ReplicatedStorage.DefaultChatSystemChatEvents.SayMessageRequest:FireServer(string.format("[%s]: %s", rainbowName, message), "All")

What this script does is that when a player joins the game, it checks if they have purchased the gamepass with ID GAMEPASS_ID. If they have, it connects to their Chatted event and modifies their name to be rainbow-colored whenever they send a message in chat.

Let me know if you have any questions!

Thank You! Where should I put this script?

You’re welcome! You can put this script in a Script object in ServerScriptService.

Make sure to replace GAMEPASS_ID_HERE with the actual ID of your Rainbow Nametag gamepass, and adjust the RGB values in RAINBOW_COLOR to your desired rainbow color. Once you’ve made these changes, you can save the script and it will automatically run when a player joins the game and purchases the gamepass.

Alrighty! Is the rainbow tag moving?

Yes, the rainbow tag should appear to be moving as each character in the player’s name will have a slightly different color. This is achieved by generating a random RGB color value for each character in the player’s name, resulting in a rainbow effect.

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