TagAPI:UpdateClientSettings
The TagAPI:UpdateClientSettings method updates a player's system message visibility preferences. Players can enable or disable specific system message types, giving them control over which notifications they receive.
Overview
Server, Clientboolean, stringSyntax
local success, message = TagAPI:UpdateClientSettings(player: Player, preferences: table)
| Parameter | Type | Description |
|---|---|---|
player |
Player |
The player whose settings should be updated |
preferences |
table |
Dictionary with message names as keys and boolean values (true = enabled, false = disabled) |
Return Values
| Return | Type | Description |
|---|---|---|
success |
boolean |
True if settings were updated successfully, false otherwise |
message |
string |
Descriptive message about the operation result |
Basic Usage
Update a player's message preferences.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local CCTFF = require(ReplicatedStorage:WaitForChild("CCTFF"))
local TagAPI = CCTFF.TagAPI
local preferences = {
["ServerRestart"] = true, -- Enable
["GameTip"] = false, -- Disable
["EventStart"] = true -- Enable
}
local success, msg = TagAPI:UpdateClientSettings(player, preferences)
if success then
print("Settings updated")
else
print("Error: " .. msg)
end
Disable All Tips
Turn off all tip messages for a player.
local function disableAllTips(player)
local tipMessages = {
"GameTip",
"DailyTip",
"ProTip",
"BeginnerTip"
}
local prefs = {}
for _, tipName in ipairs(tipMessages) do
prefs[tipName] = false
end
TagAPI:UpdateClientSettings(player, prefs)
print("Disabled all tips for " .. player.Name)
end
disableAllTips(player)
Settings Menu UI
Create a settings menu for players to control messages.
-- LocalScript
local player = game.Players.LocalPlayer
local TagAPI = require(game.ReplicatedStorage.CustomChatTagsClientAPI)
local MESSAGE_CATEGORIES = {
{name = "ServerRestart", label = "Server Restart Warnings"},
{name = "EventStart", label = "Event Notifications"},
{name = "GameTip", label = "Gameplay Tips"},
{name = "Achievement", label = "Achievement Broadcasts"},
{name = "PlayerJoin", label = "Player Join Messages"}
}
-- Create toggle buttons for each message type
local function createSettingsUI()
local currentPrefs = {}
for _, category in ipairs(MESSAGE_CATEGORIES) do
local checkbox = script.Parent:FindFirstChild(category.name .. "Toggle")
if checkbox then
checkbox.MouseButton1Click:Connect(function()
local newState = not checkbox.Selected
checkbox.Selected = newState
currentPrefs[category.name] = newState
TagAPI:UpdateClientSettings(currentPrefs)
print("Updated " .. category.name .. " to " .. tostring(newState))
end)
end
end
end
createSettingsUI()
VIP Message Preferences
Give VIP players more control over messages.
local function setupVIPPreferences(player)
if not TagAPI:HasTag(player, "VIP") then
return false, "Not a VIP player"
end
-- VIPs get all announcements disabled by default
local vipPrefs = {
["GameTip"] = false,
["PlayerJoin"] = false,
["ShopUpdate"] = false,
["ServerLoad"] = false
}
TagAPI:UpdateClientSettings(player, vipPrefs)
print("VIP preferences applied for " .. player.Name)
return true
end
setupVIPPreferences(player)
Save Preferences
Persist player message preferences with DataStore.
local DataStoreService = game:GetService("DataStoreService")
local prefsStore = DataStoreService:GetDataStore("MessagePreferences")
local function savePreferences(player, preferences)
local success, err = pcall(function()
prefsStore:SetAsync(player.UserId, preferences)
end)
if success then
TagAPI:UpdateClientSettings(player, preferences)
return true, "Preferences saved"
else
return false, "Failed to save: " .. err
end
end
local function loadPreferences(player)
local success, prefs = pcall(function()
return prefsStore:GetAsync(player.UserId)
end)
if success and prefs then
TagAPI:UpdateClientSettings(player, prefs)
print("Loaded preferences for " .. player.Name)
end
end
game.Players.PlayerAdded:Connect(loadPreferences)
Toggle Single Message
Toggle a specific message type on or off.
local function toggleMessageType(player, messageName, enabled)
local prefs = {
[messageName] = enabled
}
local success, msg = TagAPI:UpdateClientSettings(player, prefs)
if success then
local state = enabled and "enabled" or "disabled"
print(messageName .. " " .. state .. " for " .. player.Name)
end
return success, msg
end
-- Enable server restart messages
toggleMessageType(player, "ServerRestart", true)
-- Disable tips
toggleMessageType(player, "GameTip", false)
Preset Profiles
Allow players to choose from preset notification profiles.
local NOTIFICATION_PROFILES = {
All = {
ServerRestart = true,
EventStart = true,
GameTip = true,
Achievement = true,
PlayerJoin = true,
ShopUpdate = true
},
Important = {
ServerRestart = true,
EventStart = true,
GameTip = false,
Achievement = false,
PlayerJoin = false,
ShopUpdate = false
},
Minimal = {
ServerRestart = true,
EventStart = false,
GameTip = false,
Achievement = false,
PlayerJoin = false,
ShopUpdate = false
},
None = {
ServerRestart = false,
EventStart = false,
GameTip = false,
Achievement = false,
PlayerJoin = false,
ShopUpdate = false
}
}
local function setNotificationProfile(player, profileName)
local profile = NOTIFICATION_PROFILES[profileName]
if not profile then
return false, "Invalid profile: " .. profileName
end
TagAPI:UpdateClientSettings(player, profile)
print("Set " .. profileName .. " profile for " .. player.Name)
return true
end
-- Set to "Important" profile
setNotificationProfile(player, "Important")
Command System
Allow players to configure via chat commands.
local function handleMessageCommand(player, args)
local action = args[1] -- "enable" or "disable"
local messageName = args[2]
if not action or not messageName then
return false, "Usage: /messages [enable/disable] [messageName]"
end
local enabled = action:lower() == "enable"
local prefs = {
[messageName] = enabled
}
local success, msg = TagAPI:UpdateClientSettings(player, prefs)
if success then
local state = enabled and "enabled" or "disabled"
return true, messageName .. " notifications " .. state
else
return false, msg
end
end
-- Usage: /messages disable GameTip
-- Usage: /messages enable EventStart
Batch Update
Update multiple message preferences at once.
local function batchUpdatePreferences(player, updates)
local currentPrefs = {} -- Load from storage or cache
-- Merge updates into current preferences
for messageName, enabled in pairs(updates) do
currentPrefs[messageName] = enabled
end
return TagAPI:UpdateClientSettings(player, currentPrefs)
end
-- Update multiple at once
local updates = {
GameTip = false,
EventStart = true,
Achievement = true,
PlayerJoin = false
}
batchUpdatePreferences(player, updates)
Default Preferences
Set default preferences for new players.
local DEFAULT_PREFERENCES = {
ServerRestart = true,
EventStart = true,
GameTip = true,
Achievement = true,
PlayerJoin = true,
ShopUpdate = true,
MaintenanceWarning = true
}
game.Players.PlayerAdded:Connect(function(player)
task.wait(2) -- Wait for data to load
TagAPI:UpdateClientSettings(player, DEFAULT_PREFERENCES)
print("Applied default message preferences for " .. player.Name)
end)
Reset to Defaults
Reset player preferences to default state.
local function resetToDefaults(player)
local defaults = {
ServerRestart = true,
EventStart = true,
GameTip = true,
Achievement = true,
PlayerJoin = true
}
local success, msg = TagAPI:UpdateClientSettings(player, defaults)
if success then
print("Reset preferences for " .. player.Name)
return true, "Preferences reset to defaults"
else
return false, msg
end
end
resetToDefaults(player)
Check Current Settings
Retrieve and display current message settings.
local function displayCurrentSettings(player)
local messageTypes = {
"ServerRestart",
"EventStart",
"GameTip",
"Achievement",
"PlayerJoin"
}
print("Message settings for " .. player.Name .. ":")
for _, msgType in ipairs(messageTypes) do
local enabled = TagAPI:IsSystemMessageEnabled(player, msgType)
local status = enabled and "โ Enabled" or "โ Disabled"
print(" " .. msgType .. ": " .. status)
end
end
displayCurrentSettings(player)
Client-Side UI Integration
Full client-side settings panel.
-- LocalScript
local player = game.Players.LocalPlayer
local TagAPI = require(game.ReplicatedStorage.CustomChatTagsClientAPI)
local settingsFrame = script.Parent.SettingsFrame
local saveButton = settingsFrame.SaveButton
local function saveSettings()
local preferences = {}
-- Gather checkbox states
for _, child in ipairs(settingsFrame:GetChildren()) do
if child:IsA("TextButton") and child.Name:match("Toggle$") then
local messageName = child.Name:gsub("Toggle", "")
preferences[messageName] = child.Selected
end
end
-- Update on server
local success, msg = TagAPI:UpdateClientSettings(preferences)
if success then
saveButton.Text = "โ Saved!"
saveButton.BackgroundColor3 = Color3.fromRGB(0, 200, 0)
task.wait(2)
saveButton.Text = "Save Settings"
saveButton.BackgroundColor3 = Color3.fromRGB(70, 130, 180)
else
saveButton.Text = "Error!"
saveButton.BackgroundColor3 = Color3.fromRGB(200, 0, 0)
end
end
saveButton.MouseButton1Click:Connect(saveSettings)
Admin Override
Allow admins to force message visibility.
local function forceEnableMessages(player, messageList)
if not TagAPI:HasTag(player, "Admin") then
return false, "Admin only"
end
local prefs = {}
for _, msgName in ipairs(messageList) do
prefs[msgName] = true
end
for _, targetPlayer in ipairs(game.Players:GetPlayers()) do
TagAPI:UpdateClientSettings(targetPlayer, prefs)
end
print("Force-enabled messages for all players")
return true
end
-- Force enable critical messages
forceEnableMessages(adminPlayer, {"ServerRestart", "MaintenanceWarning"})
Export Settings
Export player settings for backup or transfer.
local HttpService = game:GetService("HttpService")
local function exportPlayerSettings(player)
local settings = {
UserId = player.UserId,
Username = player.Name,
Preferences = {
ServerRestart = TagAPI:IsSystemMessageEnabled(player, "ServerRestart"),
EventStart = TagAPI:IsSystemMessageEnabled(player, "EventStart"),
GameTip = TagAPI:IsSystemMessageEnabled(player, "GameTip")
},
ExportedAt = os.time()
}
local json = HttpService:JSONEncode(settings)
return json
end
local settingsJSON = exportPlayerSettings(player)
print(settingsJSON)