TagAPI:GetEquipped
The TagAPI:GetEquipped method retrieves all tags that a player currently has equipped. Equipped tags are visible in chat and respect the configured slot limits. This method works in both server and client contexts.
Overview
Server, Clienttable (array of tag IDs)Syntax
local equippedTags = TagAPI:GetEquipped(player: Player)
| Parameter | Type | Description |
|---|---|---|
player |
Player |
The player instance to retrieve equipped tags from |
Return Values
| Return | Type | Description |
|---|---|---|
equippedTags |
table |
An array containing all currently equipped tag IDs, sorted by priority (e.g., {"Owner", "Developer", "VIP"}) |
Basic Usage
Retrieve all equipped tags for a player.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local CCTFF = require(ReplicatedStorage:WaitForChild("CCTFF"))
local TagAPI = CCTFF.TagAPI
local equippedTags = TagAPI:GetEquipped(player)
print(player.Name .. " has " .. #equippedTags .. " tags equipped")
for _, tagId in ipairs(equippedTags) do
print("Equipped: " .. tagId)
end
Check Specific Tag Equipped
Verify if a player has a specific tag equipped.
local function isTagEquipped(player, tagId)
local equippedTags = TagAPI:GetEquipped(player)
return table.find(equippedTags, tagId) ~= nil
end
if isTagEquipped(player, "Admin") then
print("Player has Admin tag equipped")
else
print("Admin tag is not equipped")
end
Count Equipped Slots
Display how many tag slots are currently used.
local function getSlotInfo(player)
local equippedTags = TagAPI:GetEquipped(player)
local maxSlots = TagAPI:GetMaxSlots() -- Usually 3
local usedSlots = #equippedTags
local availableSlots = maxSlots - usedSlots
return {
Used = usedSlots,
Available = availableSlots,
Max = maxSlots
}
end
local slotInfo = getSlotInfo(player)
print("Slots: " .. slotInfo.Used .. "/" .. slotInfo.Max)
UI Active Tags Display
Show equipped tags in a player's GUI.
-- LocalScript
local player = game.Players.LocalPlayer
local TagAPI = CCTFF.TagAPI
local equippedFrame = script.Parent.EquippedTagsFrame
local function updateEquippedDisplay()
-- Clear existing display
for _, child in ipairs(equippedFrame:GetChildren()) do
if child:IsA("TextLabel") then
child:Destroy()
end
end
-- Get equipped tags
local equippedTags = TagAPI:GetEquipped(player)
-- Create label for each equipped tag
for i, tagId in ipairs(equippedTags) do
local label = Instance.new("TextLabel")
label.Name = tagId
label.Text = tagId
label.Size = UDim2.new(0.3, 0, 0, 30)
label.Position = UDim2.new(0.05 + (i - 1) * 0.32, 0, 0.1, 0)
label.BackgroundColor3 = Color3.fromRGB(30, 41, 59)
label.TextColor3 = Color3.fromRGB(229, 231, 235)
label.Parent = equippedFrame
end
end
-- Initial update
updateEquippedDisplay()
-- Listen for changes
TagAPI.OnTagEquipped:Connect(updateEquippedDisplay)
TagAPI.OnTagUnequipped:Connect(updateEquippedDisplay)
Permission Check
Grant permissions based on equipped tags.
local ADMIN_TAGS = {"Owner", "Admin", "Moderator"}
local function hasAdminPermission(player)
local equippedTags = TagAPI:GetEquipped(player)
for _, tagId in ipairs(equippedTags) do
if table.find(ADMIN_TAGS, tagId) then
return true, tagId
end
end
return false, nil
end
local hasPermission, adminTag = hasAdminPermission(player)
if hasPermission then
print(player.Name .. " has admin permission via " .. adminTag)
end
Stat Bonuses from Equipped Tags
Apply bonuses based on which tags are equipped.
local TAG_BONUSES = {
VIP = {CoinMultiplier = 2, XPMultiplier = 1.5},
Premium = {CoinMultiplier = 1.5, XPMultiplier = 1.25},
Booster = {CoinMultiplier = 1.2, XPMultiplier = 2.0}
}
local function calculateBonuses(player)
local equippedTags = TagAPI:GetEquipped(player)
local totalCoinMult = 1
local totalXPMult = 1
for _, tagId in ipairs(equippedTags) do
local bonus = TAG_BONUSES[tagId]
if bonus then
totalCoinMult = totalCoinMult * (bonus.CoinMultiplier or 1)
totalXPMult = totalXPMult * (bonus.XPMultiplier or 1)
end
end
return {
CoinMultiplier = totalCoinMult,
XPMultiplier = totalXPMult
}
end
local bonuses = calculateBonuses(player)
print("Coin multiplier: " .. bonuses.CoinMultiplier .. "x")
Save Equipped State
Save equipped tags to DataStore for persistence.
local DataStoreService = game:GetService("DataStoreService")
local playerDataStore = DataStoreService:GetDataStore("PlayerTags")
game.Players.PlayerRemoving:Connect(function(player)
local equippedTags = TagAPI:GetEquipped(player)
local ownedTags = TagAPI:GetOwned(player)
local success, err = pcall(function()
playerDataStore:SetAsync(player.UserId, {
OwnedTags = ownedTags,
EquippedTags = equippedTags,
LastSaved = os.time()
})
end)
if success then
print("Saved equipped tags for " .. player.Name)
else
warn("Failed to save: " .. err)
end
end)
Compare Equipped vs Owned
Show which owned tags are not currently equipped.
local function getUnequippedTags(player)
local ownedTags = TagAPI:GetOwned(player)
local equippedTags = TagAPI:GetEquipped(player)
local unequipped = {}
for _, tagId in ipairs(ownedTags) do
if not table.find(equippedTags, tagId) then
table.insert(unequipped, tagId)
end
end
return unequipped
end
local unequipped = getUnequippedTags(player)
print("Unequipped tags: " .. table.concat(unequipped, ", "))
Auto-Unequip Lowest Priority
Automatically unequip the lowest priority tag when slots are full.
local function autoUnequipLowest(player)
local equippedTags = TagAPI:GetEquipped(player)
local maxSlots = TagAPI:GetMaxSlots()
if #equippedTags >= maxSlots then
-- Last tag is lowest priority
local lowestPriorityTag = equippedTags[#equippedTags]
TagAPI:Unequip(player, lowestPriorityTag)
return true, lowestPriorityTag
end
return false, nil
end
local unequipped, tagId = autoUnequipLowest(player)
if unequipped then
print("Auto-unequipped: " .. tagId)
end
Team-Based Tag Requirements
Check if player has required tags equipped for team.
local TEAM_REQUIREMENTS = {
["Elite Team"] = {"Champion", "Veteran"},
["VIP Lounge"] = {"VIP", "Premium"}
}
local function canJoinTeam(player, teamName)
local requiredTags = TEAM_REQUIREMENTS[teamName]
if not requiredTags then
return true -- No requirements
end
local equippedTags = TagAPI:GetEquipped(player)
for _, requiredTag in ipairs(requiredTags) do
local hasRequired = false
for _, equippedTag in ipairs(equippedTags) do
if equippedTag == requiredTag then
hasRequired = true
break
end
end
if hasRequired then
return true
end
end
return false
end
if canJoinTeam(player, "Elite Team") then
player.Team = game.Teams["Elite Team"]
end
Admin Command: View Equipped
Create an admin command to see player's equipped tags.
local function viewEquippedCommand(admin, args)
local targetName = args[1]
if not targetName then
return false, "Usage: !viewequipped [player]"
end
local targetPlayer = game.Players:FindFirstChild(targetName)
if not targetPlayer then
return false, "Player not found"
end
local equippedTags = TagAPI:GetEquipped(targetPlayer)
local maxSlots = TagAPI:GetMaxSlots()
local message = targetPlayer.Name .. " has " .. #equippedTags .. "/" .. maxSlots .. " tags equipped:\n"
if #equippedTags > 0 then
message = message .. table.concat(equippedTags, ", ")
else
message = message .. "No tags equipped"
end
return true, message
end
-- Register command
adminCommands["viewequipped"] = viewEquippedCommand
Priority Order Display
Show equipped tags in priority order with numbers.
local function displayEquippedWithPriority(player)
local equippedTags = TagAPI:GetEquipped(player)
print(player.Name .. "'s equipped tags (by priority):")
for i, tagId in ipairs(equippedTags) do
local priority = TagAPI:GetTagPriority(tagId)
print(i .. ". " .. tagId .. " (Priority: " .. priority .. ")")
end
end
displayEquippedWithPriority(player)
Event Listener: Tag Changes
React to changes in equipped tags.
TagAPI.OnTagEquipped:Connect(function(player, tagId)
local equippedTags = TagAPI:GetEquipped(player)
print(player.Name .. " equipped " .. tagId)
print("Now has " .. #equippedTags .. " tags equipped")
end)
TagAPI.OnTagUnequipped:Connect(function(player, tagId)
local equippedTags = TagAPI:GetEquipped(player)
print(player.Name .. " unequipped " .. tagId)
print("Now has " .. #equippedTags .. " tags equipped")
end)
Client UI Sync
Keep client UI synchronized with equipped tags.
-- LocalScript
local player = game.Players.LocalPlayer
local TagAPI = CCTFF.TagAPI
local statusLabel = script.Parent.StatusLabel
local function updateStatus()
local equippedTags = TagAPI:GetEquipped(player)
local maxSlots = TagAPI:GetMaxSlots()
statusLabel.Text = "Equipped: " .. #equippedTags .. "/" .. maxSlots
if #equippedTags >= maxSlots then
statusLabel.TextColor3 = Color3.fromRGB(255, 200, 0) -- Yellow
statusLabel.Text = statusLabel.Text .. " (FULL)"
else
statusLabel.TextColor3 = Color3.fromRGB(100, 255, 100) -- Green
end
end
-- Update every second
while true do
updateStatus()
task.wait(1)
end
Loadout Presets
Save and load different tag loadout configurations.
local playerLoadouts = {}
local function saveLoadout(player, presetName)
local equippedTags = TagAPI:GetEquipped(player)
if not playerLoadouts[player.UserId] then
playerLoadouts[player.UserId] = {}
end
playerLoadouts[player.UserId][presetName] = equippedTags
return true, "Loadout saved: " .. presetName
end
local function loadLoadout(player, presetName)
local loadouts = playerLoadouts[player.UserId]
if not loadouts or not loadouts[presetName] then
return false, "Loadout not found"
end
local savedTags = loadouts[presetName]
-- Unequip all current tags
local currentTags = TagAPI:GetEquipped(player)
for _, tagId in ipairs(currentTags) do
TagAPI:Unequip(player, tagId)
end
-- Equip saved tags
for _, tagId in ipairs(savedTags) do
TagAPI:Equip(player, tagId)
end
return true, "Loaded loadout: " .. presetName
end
-- Usage
saveLoadout(player, "Combat")
loadLoadout(player, "Combat")
Empty Slot Check
Determine if player has available equipment slots.
local function hasAvailableSlots(player)
local equippedTags = TagAPI:GetEquipped(player)
local maxSlots = TagAPI:GetMaxSlots()
local availableSlots = maxSlots - #equippedTags
return availableSlots > 0, availableSlots
end
local hasSlots, count = hasAvailableSlots(player)
if hasSlots then
print("Player has " .. count .. " available slots")
else
print("All tag slots are full")
end
Rarity Check for Equipped
Verify if player has any rare tags equipped.
local RARE_TAGS = {"Legendary", "Mythical", "Godlike"}
local function hasRareTagEquipped(player)
local equippedTags = TagAPI:GetEquipped(player)
for _, tagId in ipairs(equippedTags) do
if table.find(RARE_TAGS, tagId) then
return true, tagId
end
end
return false, nil
end
local hasRare, rareTag = hasRareTagEquipped(player)
if hasRare then
print("Player showing off: " .. rareTag)
end