Hayo!
I know this is very similar to other code, but it’s a little more efficient in some aspects.
Instead of waiting for a player to join, it relies on the ChatService to add a speaker.
This is mainly aimed as an easy way to setup group rank tags in-game. Just plop this into a Script under ServerScriptService. Customize to your liking.
Note, this also includes an override for a certain UserId, be sure to change it
--[==[ START VARIABLES ]==]--
local Players = game:GetService("Players")
local ScriptService = game:GetService("ServerScriptService")
local ChatService = require(ScriptService:WaitForChild("ChatServiceRunner").ChatService)
--[==[ END VARIABLES ]==]--
--[==[ START TABLE FOR TAGS ]==]--
--[==[
FORMAT:
["RankInGroup"] = {TagText = "TagTextHere", TagColor = Color3.fromRGB(r, g, b)}
]==]--
local ranks = {
["255"] = {TagText = "Lead Developer", TagColor = Color3.fromRGB(233,30,99)},
["250"] = {TagText = "Lead Scripter", TagColor = Color3.fromRGB(230,126,34)},
["225"] = {TagText = "Place Developer", TagColor = Color3.fromRGB(230,126,34)},
["200"] = {TagText = "Asset Developer", TagColor = Color3.fromRGB(46,204,113)},
["150"] = {TagText = "Moderator", TagColor = Color3.fromRGB(32,102,148)},
["100"] = {TagText = "Moderator-In-Training", TagColor = Color3.fromRGB(76,188,206)},
}
--[==[ END TABLE FOR TAGS ]==]--
--[==[ GROUP ID ]==]--
local groupId = 3108202
--[==[ GROUP ID ]==]--
ChatService.SpeakerAdded:Connect(function(SpeakerName) -- Wait for a speaker to be added to Chat
if game.Players:FindFirstChild(SpeakerName) then -- Makes sure the speaker is a real player
local plr = game.Players:FindFirstChild(SpeakerName) -- Get the player Object
local UserId = plr.UserId -- Getting the UserId of the speaker
local Speaker = ChatService:GetSpeaker(SpeakerName) -- Getting the Speaker Object from ChatService
if plr.UserId == 26666928 then -- Replace 26666928 with your own ID
Speaker:SetExtraData("Tags", {{TagText = "Script Developer", TagColor = Color3.fromRGB(241,196,15)}}) -- Customize the text and color to your liking
Speaker:SetExtraData("NameColor", Color3.fromRGB(241,196,15)) -- Set the name color to the tag color
elseif plr:IsInGroup(groupId) then -- If player is in the group, check the rank
local rank = plr:GetRankInGroup(groupId)
for i,tag in pairs(ranks) do -- Loop through the ranks table
if i == tostring(rank) then -- If the rank of the player is in the ranks table, set the tag accordingly
Speaker:SetExtraData("Tags", {{TagText = tag.TagText, TagColor = tag.TagColor}})
Speaker:SetExtraData("NameColor", tag.TagColor) -- Sets the name color of speaker to the tag color
end
end
end
end
end)