TagAPI:IsSystemMessageEnabled

The TagAPI:IsSystemMessageEnabled method checks whether a specific system message type is enabled for a player based on their client settings. This allows respecting player preferences before sending notifications.

Overview

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

Syntax

local isEnabled = TagAPI:IsSystemMessageEnabled(player: Player, messageName: string)

Parameter Type Description
player Player The player instance to check message preferences for
messageName string The message identifier to check (e.g., "ServerRestart", "GameTip")

Return Values

Return Type Description
isEnabled boolean True if the player has the message type enabled (or no preference set), false if disabled

Basic Usage

Check if a player has a message type enabled.

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

local isEnabled = TagAPI:IsSystemMessageEnabled(player, "GameTip")
if isEnabled then
    print(player.Name .. " has tips enabled")
else
    print(player.Name .. " has tips disabled")
end

Conditional Message Sending

Only send messages to players who have them enabled.

Lua
local function sendToEnabledPlayers(messageName, systemTag, content)
    for _, player in ipairs(game.Players:GetPlayers()) do
        if TagAPI:IsSystemMessageEnabled(player, messageName) then
            -- Send message only to this player
            local notifyRemote = ReplicatedStorage.NotifyPlayer
            notifyRemote:FireClient(player, content)
        end
    end
end

sendToEnabledPlayers("GameTip", "Info", "๐Ÿ’ก Tip: Visit the shop daily!")

Filter Recipients

Build a list of players who have a message type enabled.

Lua
local function getEnabledPlayers(messageName)
    local enabledPlayers = {}
    
    for _, player in ipairs(game.Players:GetPlayers()) do
        if TagAPI:IsSystemMessageEnabled(player, messageName) then
            table.insert(enabledPlayers, player)
        end
    end
    
    return enabledPlayers
end

local tipsEnabledPlayers = getEnabledPlayers("GameTip")
print(#tipsEnabledPlayers .. " players have tips enabled")

Targeted Announcements

Send announcements only to interested players.

Lua
local function announceEventToInterestedPlayers(eventName)
    local message = "๐ŸŽ‰ " .. eventName .. " starts in 5 minutes!"
    
    for _, player in ipairs(game.Players:GetPlayers()) do
        if TagAPI:IsSystemMessageEnabled(player, "EventStart") then
            TagAPI:SendSystemMessage(
                "EventStart_" .. eventName,
                "Alert",
                message
            )
        else
            print("Skipped " .. player.Name .. " - event messages disabled")
        end
    end
end

announceEventToInterestedPlayers("Boss Battle")

Statistics Tracking

Track how many players have specific messages enabled.

Lua
local function getMessageStatistics()
    local messageTypes = {
        "ServerRestart",
        "EventStart",
        "GameTip",
        "Achievement",
        "PlayerJoin"
    }
    
    local stats = {}
    local totalPlayers = #game.Players:GetPlayers()
    
    for _, msgType in ipairs(messageTypes) do
        local enabledCount = 0
        
        for _, player in ipairs(game.Players:GetPlayers()) do
            if TagAPI:IsSystemMessageEnabled(player, msgType) then
                enabledCount = enabledCount + 1
            end
        end
        
        stats[msgType] = {
            Enabled = enabledCount,
            Disabled = totalPlayers - enabledCount,
            Percentage = (enabledCount / totalPlayers) * 100
        }
    end
    
    return stats
end

local stats = getMessageStatistics()
for msgType, data in pairs(stats) do
    print(msgType .. ": " .. data.Percentage .. "% enabled")
end

Smart Notification System

Send notifications with fallback for disabled messages.

Lua
local function smartNotify(player, messageName, systemTag, content, fallback)
    if TagAPI:IsSystemMessageEnabled(player, messageName) then
        TagAPI:SendSystemMessage(messageName, systemTag, content)
        return true, "Message sent"
    else
        -- Use fallback method if provided
        if fallback then
            fallback(player)
        end
        
        return false, "Message disabled by player"
    end
end

-- Usage with fallback
smartNotify(
    player,
    "EventStart",
    "Alert",
    "Event starting!",
    function(p)
        -- Fallback: show in GUI instead
        local gui = p.PlayerGui:FindFirstChild("NotificationGui")
        if gui then
            gui.NotificationLabel.Text = "Event starting!"
        end
    end
)

Preference Report

Generate a report of player message preferences.

Lua
local function getPlayerPreferences(player)
    local messageTypes = {
        "ServerRestart",
        "EventStart",
        "GameTip",
        "Achievement",
        "PlayerJoin",
        "ShopUpdate"
    }
    
    local preferences = {}
    
    for _, msgType in ipairs(messageTypes) do
        preferences[msgType] = TagAPI:IsSystemMessageEnabled(player, msgType)
    end
    
    return preferences
end

local prefs = getPlayerPreferences(player)
print("Message preferences for " .. player.Name .. ":")
for msgType, enabled in pairs(prefs) do
    local status = enabled and "โœ“ Enabled" or "โœ— Disabled"
    print("  " .. msgType .. ": " .. status)
end

Admin Override Check

Force send critical messages regardless of preferences.

Lua
local CRITICAL_MESSAGES = {
    "ServerRestart",
    "ServerShutdown",
    "MaintenanceWarning",
    "SecurityAlert"
}

local function sendCriticalOrCheck(player, messageName, systemTag, content)
    local isCritical = table.find(CRITICAL_MESSAGES, messageName) ~= nil
    
    if isCritical then
        -- Always send critical messages
        TagAPI:SendSystemMessage(messageName, systemTag, content)
        return true, "Critical message sent (forced)"
    else
        -- Check preference for non-critical messages
        if TagAPI:IsSystemMessageEnabled(player, messageName) then
            TagAPI:SendSystemMessage(messageName, systemTag, content)
            return true, "Message sent"
        else
            return false, "Message disabled by player"
        end
    end
end

sendCriticalOrCheck(player, "ServerRestart", "Alert", "Server restarting in 5 minutes!")

UI Indicator

Show current message status in player UI.

Lua
-- LocalScript
local player = game.Players.LocalPlayer
local TagAPI = require(game.ReplicatedStorage.CustomChatTagsClientAPI)

local settingsFrame = script.Parent.SettingsFrame

local function updateIndicators()
    local messageTypes = {
        "ServerRestart",
        "EventStart",
        "GameTip",
        "Achievement"
    }
    
    for _, msgType in ipairs(messageTypes) do
        local indicator = settingsFrame:FindFirstChild(msgType .. "Indicator")
        
        if indicator then
            local isEnabled = TagAPI:IsSystemMessageEnabled(msgType)
            
            if isEnabled then
                indicator.BackgroundColor3 = Color3.fromRGB(0, 200, 0)
                indicator.Text = "ON"
            else
                indicator.BackgroundColor3 = Color3.fromRGB(200, 0, 0)
                indicator.Text = "OFF"
            end
        end
    end
end

-- Update every 5 seconds
while true do
    updateIndicators()
    task.wait(5)
end

Batch Check

Check multiple message types at once.

Lua
local function checkMultipleMessages(player, messageNames)
    local results = {}
    
    for _, msgName in ipairs(messageNames) do
        results[msgName] = TagAPI:IsSystemMessageEnabled(player, msgName)
    end
    
    return results
end

local toCheck = {"GameTip", "EventStart", "Achievement"}
local results = checkMultipleMessages(player, toCheck)

for msgName, enabled in pairs(results) do
    print(msgName .. ": " .. tostring(enabled))
end

Count Enabled Messages

Count how many message types a player has enabled.

Lua
local function countEnabledMessages(player)
    local messageTypes = {
        "ServerRestart",
        "EventStart",
        "GameTip",
        "Achievement",
        "PlayerJoin",
        "ShopUpdate"
    }
    
    local enabledCount = 0
    local totalCount = #messageTypes
    
    for _, msgType in ipairs(messageTypes) do
        if TagAPI:IsSystemMessageEnabled(player, msgType) then
            enabledCount = enabledCount + 1
        end
    end
    
    return enabledCount, totalCount
end

local enabled, total = countEnabledMessages(player)
print(player.Name .. " has " .. enabled .. "/" .. total .. " message types enabled")

Notification Opt-In Check

Check if player has opted into any notifications.

Lua
local function hasAnyMessagesEnabled(player)
    local messageTypes = {
        "ServerRestart",
        "EventStart",
        "GameTip",
        "Achievement",
        "PlayerJoin"
    }
    
    for _, msgType in ipairs(messageTypes) do
        if TagAPI:IsSystemMessageEnabled(player, msgType) then
            return true
        end
    end
    
    return false
end

if not hasAnyMessagesEnabled(player) then
    print(player.Name .. " has disabled all notifications")
end

Admin Command

Admin command to check player's message preferences.

Lua
local function checkMessagesCommand(admin, args)
    local targetName = args[1]
    if not targetName then
        return false, "Usage: !checkmsg [player]"
    end
    
    local targetPlayer = game.Players:FindFirstChild(targetName)
    if not targetPlayer then
        return false, "Player not found"
    end
    
    local messageTypes = {
        "ServerRestart",
        "EventStart",
        "GameTip",
        "Achievement"
    }
    
    local message = targetPlayer.Name .. "'s message preferences:\n"
    
    for _, msgType in ipairs(messageTypes) do
        local enabled = TagAPI:IsSystemMessageEnabled(targetPlayer, msgType)
        local status = enabled and "โœ“ Enabled" or "โœ— Disabled"
        message = message .. "โ€ข " .. msgType .. ": " .. status .. "\n"
    end
    
    return true, message
end

adminCommands["checkmsg"] = checkMessagesCommand

Default Preference Logic

Handle default enabled state for new message types.

Lua
local DEFAULT_ENABLED_MESSAGES = {
    "ServerRestart",
    "MaintenanceWarning",
    "SecurityAlert"
}

local function isEnabledOrDefault(player, messageName)
    local isEnabled = TagAPI:IsSystemMessageEnabled(player, messageName)
    
    -- If explicitly set, use that value
    if isEnabled ~= nil then
        return isEnabled
    end
    
    -- Otherwise check if it's in default enabled list
    return table.find(DEFAULT_ENABLED_MESSAGES, messageName) ~= nil
end

local shouldSend = isEnabledOrDefault(player, "ServerRestart")
print("Should send: " .. tostring(shouldSend))

Preference Export

Export player preferences for backup.

Lua
local HttpService = game:GetService("HttpService")

local function exportPlayerMessagePreferences(player)
    local messageTypes = {
        "ServerRestart",
        "EventStart",
        "GameTip",
        "Achievement",
        "PlayerJoin",
        "ShopUpdate"
    }
    
    local preferences = {
        UserId = player.UserId,
        Username = player.Name,
        Timestamp = os.time(),
        Messages = {}
    }
    
    for _, msgType in ipairs(messageTypes) do
        preferences.Messages[msgType] = TagAPI:IsSystemMessageEnabled(player, msgType)
    end
    
    local json = HttpService:JSONEncode(preferences)
    return json
end

local prefsJSON = exportPlayerMessagePreferences(player)
print(prefsJSON)

Migration Helper

Migrate players from old to new message system.

Lua
local OLD_TO_NEW_MESSAGE_MAP = {
    ["tips"] = "GameTip",
    ["events"] = "EventStart",
    ["announcements"] = "ServerRestart"
}

local function migrateOldPreferences(player, oldPrefs)
    local newPrefs = {}
    
    for oldName, newName in pairs(OLD_TO_NEW_MESSAGE_MAP) do
        if oldPrefs[oldName] ~= nil then
            newPrefs[newName] = oldPrefs[oldName]
        end
    end
    
    if next(newPrefs) then
        TagAPI:UpdateClientSettings(player, newPrefs)
        print("Migrated preferences for " .. player.Name)
    end
end

-- Usage
local oldPreferences = {tips = false, events = true}
migrateOldPreferences(player, oldPreferences)

Notification Summary

Show player a summary of their notification settings.

Lua
local function showNotificationSummary(player)
    local messageTypes = {
        {name = "ServerRestart", label = "Server Restart Warnings"},
        {name = "EventStart", label = "Event Notifications"},
        {name = "GameTip", label = "Gameplay Tips"},
        {name = "Achievement", label = "Achievement Broadcasts"}
    }
    
    local summary = "Your Notification Settings:\n\n"
    
    for _, msgInfo in ipairs(messageTypes) do
        local enabled = TagAPI:IsSystemMessageEnabled(player, msgInfo.name)
        local icon = enabled and "๐Ÿ””" or "๐Ÿ”•"
        local status = enabled and "On" or "Off"
        
        summary = summary .. icon .. " " .. msgInfo.label .. ": " .. status .. "\n"
    end
    
    local notifyRemote = ReplicatedStorage.NotifyPlayer
    notifyRemote:FireClient(player, summary)
end

showNotificationSummary(player)