Insert UIGradient into a chat tag

How would I insert a UIGradient into a chat tag, the script below is the script that makes the tag.

how would i make the 5 stars have a uigradient?

local ServerScriptService = game:GetService("ServerScriptService")

local ChatServiceRunner = ServerScriptService:WaitForChild("ChatServiceRunner")
local ChatService = require(ChatServiceRunner.ChatService)

local SPECIAL_DATA = {
	[1150243824] = { -- change id here
		ChatColor = BrickColor.new("Really black").Color,
		Tags = {
			{
				TagText = "★★★★★",
				TagColor = BrickColor.new("Really black").Color,

			},

			{
				TagText = "Owner",
				TagColor = BrickColor.new("Really black").Color,

			},

		}
		-- Other message formats here
	},

	[412276884] = {
		ChatColor = BrickColor.new("Really black").Color,
		Tags = {
			{
				TagText = "★★★★★",
				TagColor = BrickColor.new("Really black").Color,

			},

			{
				TagText = "Owner",
				TagColor = BrickColor.new("Really black").Color,

			},

		}
		-- Other message formats here
	},

}

local function handleSpeaker(speakerName)
	local speaker = ChatService:GetSpeaker(speakerName)
	local player = speaker:GetPlayer()

	if player then
		local extraData = SPECIAL_DATA[player.UserId]
		if extraData then
			for key, value in pairs(extraData) do
				speaker:SetExtraData(key, value)
			end
		end
	end
end

ChatService.SpeakerAdded:Connect(handleSpeaker)
for _, speakerName in pairs(ChatService:GetSpeakerList()) do
	handleSpeaker(speakerName)
end

Try putting this code into a LocalScript in StarterPlayerScripts, and parenting a UIGradient to the LocalScript:

local chat = script.Parent.Parent:WaitForChild("PlayerGui"):WaitForChild("Chat")
local chatScroller = chat:WaitForChild("Frame"):WaitForChild("ChatChannelParentFrame"):WaitForChild("Frame_MessageLogDisplay"):WaitForChild("Scroller")
local UIGradient = script.UIGradient

chatScroller.DescendantAdded:Connect(function(descendant)
	if descendant:IsA("TextLabel") then
		if descendant.Text == "[★★★★★] " then
			descendant.BackgroundTransparency = 1
			descendant.TextColor3 = Color3.fromRGB(255, 255, 255)
			local newUIGradient = UIGradient:Clone()
			newUIGradient.Parent = descendant
		end
	end
end)
2 Likes

Example place file:
chatgradient.rbxl (36.4 KB)

1 Like

Thanks a lot, this helped so much.

1 Like