I’m making a nametag system that includes checks for certain badges. I want the badges to show in order of how they’re listed in the configuration table. This includes badges that require API checks, like the VIP badge.
However, they always show in the same order:
Management, VIP, Premium, Owner, Developer
How can I guarantee the badges will always show in order of how they’re listed?
badgeConfiguration = {
VIP = {Image = "rbxassetid://86825073378399"},
Premium = {Image = "rbxassetid://117799537100372"},
Management = {minRank = 10, maxRank = 255, Image = "rbxassetid://92164685193128"},
Developer = {minRank = 20, maxRank = 255, Image = "rbxassetid://102630357000349"},
Owner = {minRank = 30, maxRank = 255, Image = "rbxassetid://129084632425218"},
}
}
local function SetupNametag(player, character)
local head = character:FindFirstChild("Head")
if not head then return end
local role = player:GetRoleInGroup(configModule.groupId)
local playerNametagGui
local icons = {}
playerNametagGui = nametagGui:Clone()
local frame = playerNametagGui.Frame
local username = frame.Username
local roleDisplay = frame.Role
username.Text = player.Name
roleDisplay.Text = role or configModule.defaultRank
for badgeName, badgeData in pairs(configModule.badgeConfiguration) do
local giveBadge = false
if badgeName == "VIP" and configModule.vipGamepass and badgeData then
local success, owns = pcall(function()
return MarketPlaceService:UserOwnsGamePassAsync(player.UserId, configModule.vipGamepass)
end)
if success and owns then
giveBadge = true
end
end
if badgeName == "Premium" and badgeData then
if player.MembershipType == Enum.MembershipType.Premium then
giveBadge = true
end
end
if badgeData.minRank and badgeData.maxRank and badgeData then
local rank = player:GetRankInGroup(configModule.groupId)
if rank >= badgeData.minRank and rank <= badgeData.maxRank then
giveBadge = true
end
end
if giveBadge then
local badgeClone = badgeTemplate:Clone()
badgeClone.Name = badgeName
badgeClone.BackgroundColor3 = configModule.badgeColor
badgeClone.UIStroke.Color = Color3.fromHSV((function(h,s,v) return h,s,v*0.7 end)(configModule.badgeColor:ToHSV()))
badgeClone.ImageLabel.Image = badgeData.Image
badgeClone.Parent = frame.Attributes.Badges
end
end
playerNametagGui.Parent = head
end