Chat coding: Working with tags and name colours?

Hello!

I’ve written up a little script for myself and got it to run in Studio, but can’t get it to work at all in Server Mode.

local Players = game:GetService("Players")
local Storage = game:GetService("ReplicatedStorage")
local ScriptService = game:GetService("ServerScriptService")
local ChatService = require(ScriptService.ChatServiceRunner.ChatService)

local Speaker

game.Players.PlayerAdded:connect(function(player)
	repeat wait() until ChatService
	if player.UserId == 20415935 then
		Speaker = ChatService:GetSpeaker(tostring(player.Name))
		print(Speaker)
		Speaker:SetExtraData("NameColor", Color3.fromRGB(0, 0, 255))
		Speaker:SetExtraData("ChatColor", Color3.fromRGB(0, 255, 0))
		Speaker:SetExtraData("Tags", {{TagText = "Developer", TagColor = Color3.fromRGB(255, 0, 255)}})
	elseif player.UserId == 558247746 then
		Speaker = ChatService:GetSpeaker(tostring(player.Name))
		Speaker:SetExtraData("NameColor", Color3.fromRGB(0, 0, 255))
		Speaker:SetExtraData("ChatColor", Color3.fromRGB(255, 0, 0))
		Speaker:SetExtraData("Tags", {{TagText = "TagText2", TagColor = Color3.fromRGB(0, 255, 0)}})
	end
end)

The Script is a Server Script and is located in ServerScriptService.

1 Like