TagAPI:Remove
The TagAPI:Remove method removes a tag from a player. This method is server-side only and requires the CCTFF framework to be properly initialized. Use this to revoke permissions, update player status, or remove expired tags.
Overview
boolean, stringSyntax
TagAPI:Remove(player: Player, tagId: string)
Parameters
| Parameter | Type | Description |
|---|---|---|
player |
Player |
The player instance who should lose the tag |
tagId |
string |
The tag identifier to remove |
Basic Usage
Remove a single tag from a player.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local CCTFF = require(ReplicatedStorage:WaitForChild("CCTFF"))
local TagAPI = CCTFF.TagAPI
-- Remove a tag from a player
TagAPI:Remove(player, "Newcomer")
Remove Multiple Tags
Remove several tags at once using a loop.
local tagsToRemove = {"VIP", "Premium", "EventTag"}
for _, tagId in ipairs(tagsToRemove) do
TagAPI:Remove(player, tagId)
end
Subscription Expiration
Remove VIP tags when a subscription expires.
local function checkSubscriptionStatus(player)
local subscriptionData = getPlayerSubscription(player)
if subscriptionData and os.time() > subscriptionData.expiryTime then
TagAPI:Remove(player, "VIP")
TagAPI:Remove(player, "PremiumMember")
end
end
game.Players.PlayerAdded:Connect(function(player)
checkSubscriptionStatus(player)
end)
Demotion System
Remove admin or moderator tags when demoting a player.
local function demotePlayer(player, fromRole)
if fromRole == "Admin" then
TagAPI:Remove(player, "Admin")
TagAPI:Give(player, "Moderator") -- Optionally give lower role
elseif fromRole == "Moderator" then
TagAPI:Remove(player, "Moderator")
end
end
-- Usage
demotePlayer(player, "Admin")
Group Rank Update
Remove old rank tags when player's group rank changes.
local GROUP_ID = 123456
local rankTags = {"Owner", "Admin", "Moderator", "Member"}
game.Players.PlayerAdded:Connect(function(player)
-- Remove all rank tags first
for _, tagId in ipairs(rankTags) do
TagAPI:Remove(player, tagId)
end
-- Then assign the correct one
local rank = player:GetRankInGroup(GROUP_ID)
if rank >= 250 then
TagAPI:Give(player, "Owner")
elseif rank >= 200 then
TagAPI:Give(player, "Admin")
end
end)
Event End Cleanup
Remove event-specific tags when an event ends.
local function endHolidayEvent()
for _, player in ipairs(game.Players:GetPlayers()) do
TagAPI:Remove(player, "HolidayParticipant")
TagAPI:Remove(player, "EventWinner")
end
end
-- Call when event ends
EventSystem.EventEnded:Connect(endHolidayEvent)
Punishment System
Remove privileges tags when punishing a player.
local function punishPlayer(player, severity)
if severity == "severe" then
TagAPI:Remove(player, "VIP")
TagAPI:Remove(player, "Trusted")
TagAPI:Remove(player, "Moderator")
elseif severity == "moderate" then
TagAPI:Remove(player, "Trusted")
end
TagAPI:Give(player, "Restricted")
end
-- Usage
punishPlayer(player, "severe")
Command System Integration
Allow administrators to remove tags via commands.
local function removeTagCommand(admin, targetPlayerName, tagId)
local targetPlayer = game.Players:FindFirstChild(targetPlayerName)
if targetPlayer then
TagAPI:Remove(targetPlayer, tagId)
return true, "Tag removed successfully!"
else
return false, "Player not found"
end
end
-- Example command handler
adminCommands["removetag"] = removeTagCommand
Team Change Cleanup
Remove team-specific tags when players switch teams.
game.Players.PlayerAdded:Connect(function(player)
player:GetPropertyChangedSignal("Team"):Connect(function()
-- Remove all team tags
TagAPI:Remove(player, "RedTeamMember")
TagAPI:Remove(player, "BlueTeamMember")
TagAPI:Remove(player, "GreenTeamMember")
-- Add new team tag
local team = player.Team
if team then
TagAPI:Give(player, team.Name .. "TeamMember")
end
end)
end)
Leaderboard Position Loss
Remove ranking tags when players drop in leaderboard position.
local function updateLeaderboardTags()
-- Remove all ranking tags from everyone
for _, player in ipairs(game.Players:GetPlayers()) do
TagAPI:Remove(player, "Champion")
TagAPI:Remove(player, "RunnerUp")
TagAPI:Remove(player, "ThirdPlace")
end
-- Sort and assign to top 3
local players = game.Players:GetPlayers()
table.sort(players, function(a, b)
return a.leaderstats.Points.Value > b.leaderstats.Points.Value
end)
if players[1] then TagAPI:Give(players[1], "Champion") end
if players[2] then TagAPI:Give(players[2], "RunnerUp") end
if players[3] then TagAPI:Give(players[3], "ThirdPlace") end
end
Premium Cancellation
Remove Premium tags when subscription is cancelled.
game.Players.PlayerAdded:Connect(function(player)
-- Check periodically
while player and player.Parent do
if player.MembershipType ~= Enum.MembershipType.Premium then
TagAPI:Remove(player, "PremiumMember")
end
task.wait(300) -- Check every 5 minutes
end
end)
Session-Based Tags
Remove temporary tags when players leave the game.
game.Players.PlayerRemoving:Connect(function(player)
-- Remove all temporary tags
TagAPI:Remove(player, "InGame")
TagAPI:Remove(player, "ActivePlayer")
TagAPI:Remove(player, "CurrentlyPlaying")
end)
Achievement Revocation
Remove achievement tags if progress is lost or reset.
local function resetPlayerProgress(player)
-- Remove all achievement tags
local achievementTags = {
"Centurion", "Veteran", "Explorer",
"Millionaire", "Wealthy", "Prosperous"
}
for _, tagId in ipairs(achievementTags) do
TagAPI:Remove(player, tagId)
end
-- Reset stats
player.leaderstats.Level.Value = 1
player.leaderstats.Coins.Value = 0
end
Time-Limited Tags
Remove tags after a specific duration.
local function giveTemporaryTag(player, tagId, duration)
TagAPI:Give(player, tagId)
task.wait(duration)
if player and player.Parent then
TagAPI:Remove(player, tagId)
end
end
-- Give a 1-hour boost tag
giveTemporaryTag(player, "DoubleXP", 3600)
Conditional Tag Removal
Remove tags based on player behavior or stats dropping below thresholds.
local function checkStatRequirements(player)
local coins = player.leaderstats.Coins.Value
if coins < 1000000 then
TagAPI:Remove(player, "Millionaire")
end
if coins < 100000 then
TagAPI:Remove(player, "Wealthy")
end
if coins < 10000 then
TagAPI:Remove(player, "Prosperous")
end
end
game.Players.PlayerAdded:Connect(function(player)
player.leaderstats.Coins.Changed:Connect(function()
checkStatRequirements(player)
end)
end)
Clear All Tags
Remove all tags from a player (useful for resets or fresh starts).
local function clearAllTags(player)
local allPossibleTags = {
"Admin", "Moderator", "VIP", "Premium",
"Veteran", "Newcomer", "Champion", "Developer"
-- Add all your tag IDs here
}
for _, tagId in ipairs(allPossibleTags) do
TagAPI:Remove(player, tagId)
end
end
-- Usage
clearAllTags(player)
Role Transition
Remove old role tags before assigning new ones.
local function setPlayerRole(player, newRole)
-- Remove all role tags
local allRoles = {"Owner", "Admin", "Moderator", "Helper", "Member"}
for _, role in ipairs(allRoles) do
TagAPI:Remove(player, role)
end
-- Add new role
TagAPI:Give(player, newRole)
end
-- Usage
setPlayerRole(player, "Moderator")
Badge Loss Handling
Remove tags if badge verification fails (edge case handling).
local BadgeService = game:GetService("BadgeService")
local BADGE_ID = 123456789
local function verifyBadgeTags(player)
local success, hasBadge = pcall(function()
return BadgeService:UserHasBadgeAsync(player.UserId, BADGE_ID)
end)
if success and not hasBadge then
TagAPI:Remove(player, "BadgeCollector")
end
end
-- Verify periodically
game.Players.PlayerAdded:Connect(function(player)
while player and player.Parent do
verifyBadgeTags(player)
task.wait(600) -- Check every 10 minutes
end
end)
Cooldown System
Remove and re-add tags to implement cooldowns.
local function usePowerUp(player)
-- Check if player has the tag
if hasTag(player, "PowerUpReady") then
TagAPI:Remove(player, "PowerUpReady")
-- Grant power up effect
applyPowerUp(player)
-- Cooldown period
task.wait(60)
if player and player.Parent then
TagAPI:Give(player, "PowerUpReady")
end
end
end