TagAPI:GetAvailableSlots
The TagAPI:GetAvailableSlots method returns the number of empty tag slots a player currently has available for equipping additional tags. This is calculated as the difference between maximum slots and currently equipped tags.
Overview
Server, ClientnumberSyntax
local availableSlots = TagAPI:GetAvailableSlots(player: Player)
| Parameter | Type | Description |
|---|---|---|
player |
Player |
The player instance to check available slots for |
Return Values
| Return | Type | Description |
|---|---|---|
availableSlots |
number |
The number of empty slots available for equipping tags (0 or more) |
Basic Usage
Check how many slots are available for a player.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local CCTFF = require(ReplicatedStorage:WaitForChild("CCTFF"))
local TagAPI = CCTFF.TagAPI
local availableSlots = TagAPI:GetAvailableSlots(player)
print(player.Name .. " has " .. availableSlots .. " available slot(s)")
Quick Slot Check
Verify if player can equip more tags.
local function hasAvailableSlot(player)
return TagAPI:GetAvailableSlots(player) > 0
end
if hasAvailableSlot(player) then
print("Player can equip more tags")
else
print("All slots are full")
end
Safe Equip Function
Check available slots before equipping a tag.
local function safeEquipTag(player, tagId)
local availableSlots = TagAPI:GetAvailableSlots(player)
if availableSlots == 0 then
return false, "No available slots. Unequip a tag first."
end
return TagAPI:Equip(player, tagId)
end
local success, message = safeEquipTag(player, "VIP")
print(message)
UI Notification
Display available slots to the player.
-- LocalScript
local player = game.Players.LocalPlayer
local TagAPI = CCTFF.TagAPI
local statusLabel = script.Parent.SlotStatus
local function updateSlotStatus()
local available = TagAPI:GetAvailableSlots(player)
if available == 0 then
statusLabel.Text = "⚠️ All slots full"
statusLabel.TextColor3 = Color3.fromRGB(255, 100, 100)
elseif available == 1 then
statusLabel.Text = "1 slot available"
statusLabel.TextColor3 = Color3.fromRGB(255, 200, 0)
else
statusLabel.Text = available .. " slots available"
statusLabel.TextColor3 = Color3.fromRGB(100, 255, 100)
end
end
-- Update every 2 seconds
while true do
updateSlotStatus()
task.wait(2)
end
Shop Purchase Logic
Disable equip button when slots are full.
-- LocalScript
local player = game.Players.LocalPlayer
local TagAPI = CCTFF.TagAPI
local equipButton = script.Parent.EquipButton
local function updateButtonState()
local available = TagAPI:GetAvailableSlots(player)
if available > 0 then
equipButton.BackgroundColor3 = Color3.fromRGB(34, 197, 94)
equipButton.Text = "Equip Tag"
equipButton.Active = true
else
equipButton.BackgroundColor3 = Color3.fromRGB(100, 100, 100)
equipButton.Text = "No Slots Available"
equipButton.Active = false
end
end
equipButton.MouseButton1Click:Connect(function()
if TagAPI:GetAvailableSlots(player) > 0 then
-- Proceed with equip
equipRemote:FireServer(selectedTagId)
end
end)
updateButtonState()
Batch Equip Validation
Check if player can equip multiple tags at once.
local function canEquipMultiple(player, tagList)
local available = TagAPI:GetAvailableSlots(player)
local needed = #tagList
if available >= needed then
return true, "All tags can be equipped"
else
local shortage = needed - available
return false, "Need " .. shortage .. " more slot(s)"
end
end
local tagsToEquip = {"VIP", "Premium", "Supporter"}
local canEquip, message = canEquipMultiple(player, tagsToEquip)
print(message)
Auto-Equip System
Automatically equip tags as slots become available.
local function autoEquipQueue(player, queue)
local available = TagAPI:GetAvailableSlots(player)
local equipped = 0
for i = 1, math.min(available, #queue) do
local tagId = queue[i]
local success = TagAPI:Equip(player, tagId)
if success then
equipped = equipped + 1
table.remove(queue, 1)
end
end
return equipped, queue
end
local equipQueue = {"VIP", "Premium", "Supporter", "Champion"}
local count, remaining = autoEquipQueue(player, equipQueue)
print("Equipped " .. count .. " tags")
print("Remaining in queue: " .. #remaining)
Warning Before Full
Alert player when they have one slot left.
TagAPI.OnTagEquipped:Connect(function(player, tagId)
local available = TagAPI:GetAvailableSlots(player)
if available == 1 then
local notifyRemote = ReplicatedStorage.NotifyPlayer
notifyRemote:FireClient(
player,
"Warning: Only 1 tag slot remaining!"
)
elseif available == 0 then
local notifyRemote = ReplicatedStorage.NotifyPlayer
notifyRemote:FireClient(
player,
"All tag slots are now full. Unequip a tag to equip another."
)
end
end)
Slot Progress Bar
Create a visual progress bar showing slot usage.
-- LocalScript
local player = game.Players.LocalPlayer
local TagAPI = CCTFF.TagAPI
local progressBar = script.Parent.ProgressBar
local function updateProgressBar()
local maxSlots = TagAPI:GetMaxSlots(player)
local available = TagAPI:GetAvailableSlots(player)
local used = maxSlots - available
local fillPercentage = used / maxSlots
progressBar.Size = UDim2.new(fillPercentage, 0, 1, 0)
-- Color based on usage
if fillPercentage >= 1.0 then
progressBar.BackgroundColor3 = Color3.fromRGB(255, 0, 0) -- Red
elseif fillPercentage >= 0.75 then
progressBar.BackgroundColor3 = Color3.fromRGB(255, 165, 0) -- Orange
else
progressBar.BackgroundColor3 = Color3.fromRGB(0, 255, 0) -- Green
end
end
while true do
updateProgressBar()
task.wait(1)
end
Conditional Tag Giving
Only give tags if player has room to equip them.
local function giveAndEquipIfPossible(player, tagId)
-- Give the tag
local gaveTag, message = TagAPI:Give(player, tagId)
if not gaveTag then
return false, message
end
-- Try to equip if slots available
local available = TagAPI:GetAvailableSlots(player)
if available > 0 then
TagAPI:Equip(player, tagId)
return true, "Tag given and equipped"
else
return true, "Tag given but no slots available to equip"
end
end
local success, message = giveAndEquipIfPossible(player, "NewTag")
print(message)
Slot Fullness Percentage
Calculate what percentage of slots are filled.
local function getSlotFullnessPercentage(player)
local maxSlots = TagAPI:GetMaxSlots(player)
local available = TagAPI:GetAvailableSlots(player)
local used = maxSlots - available
local percentage = (used / maxSlots) * 100
return math.floor(percentage)
end
local fullness = getSlotFullnessPercentage(player)
print("Slots are " .. fullness .. "% full")
Leaderboard Display
Show available slots in leaderstats.
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local availableSlots = Instance.new("IntValue")
availableSlots.Name = "Available Slots"
availableSlots.Value = TagAPI:GetAvailableSlots(player)
availableSlots.Parent = leaderstats
-- Update when tags change
TagAPI.OnTagEquipped:Connect(function(p)
if p == player then
availableSlots.Value = TagAPI:GetAvailableSlots(player)
end
end)
TagAPI.OnTagUnequipped:Connect(function(p)
if p == player then
availableSlots.Value = TagAPI:GetAvailableSlots(player)
end
end)
end)
Smart Loadout Manager
Load as many tags from a loadout as possible.
local function loadSmartLoadout(player, loadout)
-- Unequip all first
TagAPI:UnequipAll(player)
local available = TagAPI:GetAvailableSlots(player)
local toEquip = math.min(#loadout, available)
local equipped = 0
for i = 1, toEquip do
local success = TagAPI:Equip(player, loadout[i])
if success then
equipped = equipped + 1
end
end
return equipped, toEquip
end
local myLoadout = {"Owner", "Developer", "VIP", "Premium"}
local equipped, attempted = loadSmartLoadout(player, myLoadout)
print("Equipped " .. equipped .. "/" .. attempted .. " tags from loadout")
Priority Queue System
Equip highest priority tags based on available slots.
local TAG_PRIORITIES = {
Owner = 1,
Admin = 2,
Moderator = 3,
VIP = 4,
Premium = 5
}
local function equipByPriority(player)
local ownedTags = TagAPI:GetOwned(player)
local available = TagAPI:GetAvailableSlots(player)
-- Sort by priority
table.sort(ownedTags, function(a, b)
local pA = TAG_PRIORITIES[a] or 999
local pB = TAG_PRIORITIES[b] or 999
return pA < pB
end)
-- Equip highest priority tags
for i = 1, math.min(available, #ownedTags) do
TagAPI:Equip(player, ownedTags[i])
end
end
equipByPriority(player)
Admin Command
Check available slots via admin command.
local function checkAvailableCommand(admin, args)
local targetName = args[1]
if not targetName then
return false, "Usage: !available [player]"
end
local targetPlayer = game.Players:FindFirstChild(targetName)
if not targetPlayer then
return false, "Player not found"
end
local available = TagAPI:GetAvailableSlots(targetPlayer)
local maxSlots = TagAPI:GetMaxSlots(targetPlayer)
local used = maxSlots - available
local message = targetPlayer.Name .. " has " .. available .. " available slot(s)\n" ..
"Using: " .. used .. "/" .. maxSlots
return true, message
end
adminCommands["available"] = checkAvailableCommand
Achievement System
Award achievement for filling all slots.
TagAPI.OnTagEquipped:Connect(function(player, tagId)
local available = TagAPI:GetAvailableSlots(player)
if available == 0 then
-- Player filled all slots
if not TagAPI:HasTag(player, "SlotMaster") then
TagAPI:Give(player, "SlotMaster")
local notifyRemote = ReplicatedStorage.NotifyPlayer
notifyRemote:FireClient(
player,
"Achievement Unlocked: Slot Master!"
)
end
end
end)