TagAPI:HasTag

The TagAPI:HasTag method checks whether a player owns a specific tag. This is a boolean check that returns true if the player has the tag in their collection, regardless of whether it's equipped. Works in both server and client contexts.

Overview

Execution Context
Server, Client
Script Type
Server Script, Local Script
Returns
boolean
Side Effects
None - read-only operation

Syntax

local hasTag = TagAPI:HasTag(player: Player, tagId: string)

Parameter Type Description
player Player The player instance to check
tagId string The tag identifier to check for

Return Values

Return Type Description
hasTag boolean True if the player owns the specified tag, false otherwise

Basic Usage

Check if a player owns a specific tag.

Lua
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local CCTFF = require(ReplicatedStorage:WaitForChild("CCTFF"))
local TagAPI = CCTFF.TagAPI

if TagAPI:HasTag(player, "VIP") then
    print(player.Name .. " is a VIP!")
else
    print(player.Name .. " is not a VIP")
end

Permission Gating

Restrict access to features based on tag ownership.

Lua
local function canAccessVIPArea(player)
    if TagAPI:HasTag(player, "VIP") or TagAPI:HasTag(player, "Premium") then
        return true
    end
    return false
end

-- Check access when player touches door
local vipDoor = workspace.VIPDoor

vipDoor.Touched:Connect(function(hit)
    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
    if not player then return end
    
    if canAccessVIPArea(player) then
        vipDoor.CanCollide = false
        wait(2)
        vipDoor.CanCollide = true
    else
        print("VIP access required!")
    end
end)

Conditional Tag Giving

Award tags only if player doesn't already have them.

Lua
local function giveFirstTimeTag(player)
    if not TagAPI:HasTag(player, "Newcomer") then
        TagAPI:Give(player, "Newcomer")
        print("Welcome! You received the Newcomer tag")
    else
        print("Welcome back!")
    end
end

game.Players.PlayerAdded:Connect(giveFirstTimeTag)

Multiple Tag Check

Verify if player has any tags from a list.

Lua
local ADMIN_TAGS = {"Owner", "Admin", "Moderator"}

local function hasAnyAdminTag(player)
    for _, tagId in ipairs(ADMIN_TAGS) do
        if TagAPI:HasTag(player, tagId) then
            return true, tagId
        end
    end
    return false, nil
end

local isAdmin, adminTag = hasAnyAdminTag(player)
if isAdmin then
    print(player.Name .. " has admin via " .. adminTag)
end

Require All Tags

Check if player owns all tags from a required set.

Lua
local function hasAllRequiredTags(player, requiredTags)
    for _, tagId in ipairs(requiredTags) do
        if not TagAPI:HasTag(player, tagId) then
            return false, tagId
        end
    end
    return true, nil
end

local requiredSet = {"Fighter", "Warrior", "Champion"}
local hasAll, missingTag = hasAllRequiredTags(player, requiredSet)

if hasAll then
    TagAPI:Give(player, "Combat Master")
    print("Combat Master achievement unlocked!")
else
    print("Still need: " .. missingTag)
end

Shop Purchase Validation

Prevent duplicate tag purchases.

Lua
local function purchaseTag(player, tagId, cost)
    -- Check if already owned
    if TagAPI:HasTag(player, tagId) then
        return false, "You already own this tag!"
    end
    
    -- Check if player has enough currency
    local coins = player.leaderstats.Coins.Value
    if coins < cost then
        return false, "Not enough coins!"
    end
    
    -- Process purchase
    player.leaderstats.Coins.Value -= cost
    TagAPI:Give(player, tagId)
    
    return true, "Tag purchased successfully!"
end

local success, message = purchaseTag(player, "Premium", 5000)
print(message)

Achievement Progress

Track achievement progress based on tag ownership.

Lua
local ACHIEVEMENT_TAGS = {
    "Explorer", "Adventurer", "Traveler", 
    "Discoverer", "Pathfinder", "Navigator"
}

local function getAchievementProgress(player)
    local ownedCount = 0
    
    for _, tagId in ipairs(ACHIEVEMENT_TAGS) do
        if TagAPI:HasTag(player, tagId) then
            ownedCount += 1
        end
    end
    
    local progress = (ownedCount / #ACHIEVEMENT_TAGS) * 100
    return ownedCount, #ACHIEVEMENT_TAGS, progress
end

local owned, total, percent = getAchievementProgress(player)
print("Achievement progress: " .. owned .. "/" .. total .. " (" .. percent .. "%)")

Client UI Toggle

Show or hide UI elements based on tag ownership.

Lua
-- LocalScript
local player = game.Players.LocalPlayer
local TagAPI = CCTFF.TagAPI

local vipButton = script.Parent.VIPButton
local premiumButton = script.Parent.PremiumButton

-- Show/hide based on ownership
vipButton.Visible = TagAPI:HasTag(player, "VIP")
premiumButton.Visible = TagAPI:HasTag(player, "Premium")

-- Update when tags change
TagAPI.OnTagAdded:Connect(function(updatedPlayer, tagId)
    if updatedPlayer == player then
        if tagId == "VIP" then
            vipButton.Visible = true
        elseif tagId == "Premium" then
            premiumButton.Visible = true
        end
    end
end)

Boost Eligibility

Check if player can receive special boosts.

Lua
local function applyLoginBoost(player)
    local boostMultiplier = 1
    
    if TagAPI:HasTag(player, "VIP") then
        boostMultiplier += 0.5
    end
    
    if TagAPI:HasTag(player, "Premium") then
        boostMultiplier += 0.25
    end
    
    if TagAPI:HasTag(player, "Supporter") then
        boostMultiplier += 0.15
    end
    
    -- Award daily bonus with multiplier
    local baseBonus = 1000
    local totalBonus = baseBonus * boostMultiplier
    
    player.leaderstats.Coins.Value += totalBonus
    print("Login bonus: " .. totalBonus .. " coins (" .. boostMultiplier .. "x)")
end

game.Players.PlayerAdded:Connect(applyLoginBoost)

Tag Requirement Display

Show which required tags player is missing.

Lua
local function displayMissingTags(player, requiredTags)
    local missing = {}
    
    for _, tagId in ipairs(requiredTags) do
        if not TagAPI:HasTag(player, tagId) then
            table.insert(missing, tagId)
        end
    end
    
    if #missing == 0 then
        return "All requirements met!"
    else
        return "Missing tags: " .. table.concat(missing, ", ")
    end
end

local required = {"Fighter", "Warrior"}
local message = displayMissingTags(player, required)
print(message)

Leaderboard Filtering

Filter players for leaderboards based on tag ownership.

Lua
local function getPlayersWithTag(tagId)
    local playersWithTag = {}
    
    for _, player in ipairs(game.Players:GetPlayers()) do
        if TagAPI:HasTag(player, tagId) then
            table.insert(playersWithTag, player)
        end
    end
    
    return playersWithTag
end

-- Get all VIP players for special leaderboard
local vipPlayers = getPlayersWithTag("VIP")
print("VIP players online: " .. #vipPlayers)

for _, player in ipairs(vipPlayers) do
    print("- " .. player.Name)
end

Subscription Check

Verify active subscription status via tag.

Lua
local function hasActiveSubscription(player)
    local subscriptionTags = {
        Monthly = TagAPI:HasTag(player, "MonthlySubscriber"),
        Yearly = TagAPI:HasTag(player, "YearlySubscriber"),
        Lifetime = TagAPI:HasTag(player, "LifetimeSubscriber")
    }
    
    if subscriptionTags.Lifetime then
        return true, "Lifetime"
    elseif subscriptionTags.Yearly then
        return true, "Yearly"
    elseif subscriptionTags.Monthly then
        return true, "Monthly"
    else
        return false, "None"
    end
end

local hasSubscription, tier = hasActiveSubscription(player)
print("Subscription: " .. tier)

Event Participation

Check if player has event-specific tags.

Lua
local function canJoinEvent(player, eventTag)
    if not TagAPI:HasTag(player, eventTag) then
        return false, "You need the " .. eventTag .. " tag to join this event"
    end
    
    return true, "Welcome to the event!"
end

-- Halloween event check
local canJoin, message = canJoinEvent(player, "Halloween2025")
print(message)

if canJoin then
    player:LoadCharacter() -- Teleport to event
end

Cumulative Benefits

Stack benefits from multiple tag ownership.

Lua
local SPEED_BOOST_TAGS = {
    VIP = 5,
    Premium = 10,
    Supporter = 3,
    Champion = 15
}

local function calculateSpeedBoost(player)
    local totalBoost = 0
    
    for tagId, boostAmount in pairs(SPEED_BOOST_TAGS) do
        if TagAPI:HasTag(player, tagId) then
            totalBoost += boostAmount
        end
    end
    
    return totalBoost
end

local speedBoost = calculateSpeedBoost(player)
if speedBoost > 0 then
    local character = player.Character
    if character and character:FindFirstChild("Humanoid") then
        character.Humanoid.WalkSpeed = 16 + speedBoost
        print("Speed boost applied: +" .. speedBoost)
    end
end

Warning System Bypass

Check if player has immunity tags.

Lua
local function canWarnPlayer(admin, targetPlayer)
    -- Check if target has immunity
    if TagAPI:HasTag(targetPlayer, "Owner") then
        return false, "Cannot warn the owner"
    end
    
    if TagAPI:HasTag(targetPlayer, "Admin") and not TagAPI:HasTag(admin, "Owner") then
        return false, "Cannot warn admins unless you're the owner"
    end
    
    return true, "Warning issued"
end

local canWarn, message = canWarnPlayer(adminPlayer, targetPlayer)
print(message)

Unlock Notification

Notify player when they unlock specific tags.

Lua
TagAPI.OnTagAdded:Connect(function(player, tagId)
    -- Check if this is a rare tag
    local rareTags = {"Legendary", "Mythical", "Godlike"}
    
    if table.find(rareTags, tagId) then
        -- Send notification to all players
        for _, otherPlayer in ipairs(game.Players:GetPlayers()) do
            local notifyRemote = ReplicatedStorage.NotifyEvent
            notifyRemote:FireClient(
                otherPlayer, 
                player.Name .. " unlocked the " .. tagId .. " tag!"
            )
        end
    end
end)