How to make a chat name tag for player that own a badge

What do you want to achieve?
I want to make a chat name tag that you have when you own a badge.

What is the issue?
I know how to make a chat name tag for people who have a gamepass but I don’t know how to do for a badge.

What solutions have you tried so far?
I searched on the internet but I found nothing.

3 Likes

Try checking these out.

Custom Chat Tag (Devforum Tutorial)
BadgeService (Roblox Documentation)

1 Like

I’ll try that. Thanks for helping! Have a good day!

One of the links is for the badge and one is for the chat name tag, but I don’t know how to combine these two scripts (maybe it’s easy to do but sorry I’m very bad at scripting)!

Okay, I will give you a script tomorrow since I need to go now.

local BadgeService = game:GetService("BadgeService")
local BadgeId = 123456 -- Replace with your badge ID

--@https://devforum.roblox.com/t/how-to-create-a-custom-chat-tag/735593
local ServerScriptService = game:GetService("ServerScriptService")
local ChatService = require(ServerScriptService:WaitForChild("ChatServiceRunner").ChatService)

local TAGS = {
	[0] = {TagText = "TagText", TagColor = Color3.fromRGB(255, 0, 0)},
}

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

	-- Safe, as if statement fails if first condition is falsy
	if player and BadgeService:UserHasBadgeAsync(player.UserId, BadgeId) then
		-- Wrap tag in table, as Tags expects a table value worth of tags
		speaker:SetExtraData("Tags", {TAGS[player.UserId]})
	end
end
ChatService.SpeakerAdded:Connect(speakerAdded)
for _, speaker in ipairs(ChatService:GetSpeakerList()) do
	speakerAdded(speaker)
end
3 Likes

Thanks! And I just put it in workspace?

Put it in ServerScriptService.

Ok thanks! I’ll try that tomorrow. Have a good day!