Moderation
Global moderation system for managing player behavior in your world. Provides ban, kick, mute functionality with event notifications and ban list retrieval.
IMPORTANT: Server-side only. Rate limited.
Use cases:
- Ban disruptive players temporarily or permanently
- Kick players to immediately remove them from the world
- Mute players to prevent them from chatting
- Listen to moderation events to log actions or notify moderators
- Retrieve banned users list for moderation UI
Available on: Server scripts only
Properties
Event fired when a player is banned.
Event Parameters: userId (string): The user ID of the banned player durationSeconds (number): Ban duration in seconds (or InfiniteDuration) message (string): The ban reason message
Moderation.OnBan:Connect(function(userId, durationSeconds, message)
print("BANNED: " .. userId)
print("Duration: " .. durationSeconds .. " seconds")
print("Reason: " .. message)
-- Log to storage
Storage.SetValue("BanLog_" .. userId, {
timestamp = os.time(),
duration = durationSeconds,
reason = message
})
end)
Event fired when a player is kicked from the world.
Event Parameters: userId (string): The user ID of the kicked player
Moderation.OnKick:Connect(function(userId)
print("KICKED: " .. userId)
end)
Event fired when a player is muted.
Event Parameters: userId (string): The user ID of the muted player durationSeconds (number): Mute duration in seconds (or InfiniteDuration)
Moderation.OnMute:Connect(function(userId, durationSeconds)
print("MUTED: " .. userId .. " for " .. durationSeconds .. " seconds")
end)
Event fired when a player is unbanned.
Event Parameters: userId (string): The user ID of the unbanned player
Moderation.OnUnban:Connect(function(userId)
print("UNBANNED: " .. userId)
Storage.DeleteValue("BanLog_" .. userId)
end)
Event fired when a player is unmuted.
Event Parameters: userId (string): The user ID of the unmuted player
Moderation.OnUnmute:Connect(function(userId)
print("UNMUTED: " .. userId)
end)
Constant value representing a permanent/infinite duration for bans and mutes. Use this instead of a large number to indicate a permanent action.
-- Permanently ban a player
Moderation.BanPlayer(player, Moderation.InfiniteDuration, "Permanent ban")
-- Permanently mute a player
Moderation.MutePlayer(player, Moderation.InfiniteDuration)
Methods
Bans a user by their user ID.
Overloads:
- Ban(userId, duration)
- Ban(userId, duration, message)
- Ban(userId, duration, message, callback)
Use Moderation.InfiniteDuration for permanent bans.
-- Ban for 1 hour (3600 seconds)
Moderation.Ban("user_123", 3600)
-- Ban with reason
Moderation.Ban("user_123", 3600, "Spamming chat")
-- Ban with error handling
Moderation.Ban("user_123", 3600, "Inappropriate behavior", function(error)
if error == ModerationError.None then
print("Ban successful")
elseif error == ModerationError.InvalidUserId then
print("User ID not found")
elseif error == ModerationError.InsufficientPermissions then
print("No permission to ban")
end
end)
-- Permanent ban
Moderation.Ban("user_123", Moderation.InfiniteDuration, "Permanent ban")
Parameters
userId
durationSeconds
Returns
Bans a user by their user ID.
Overloads:
- Ban(userId, duration)
- Ban(userId, duration, message)
- Ban(userId, duration, message, callback)
Use Moderation.InfiniteDuration for permanent bans.
-- Ban for 1 hour (3600 seconds)
Moderation.Ban("user_123", 3600)
-- Ban with reason
Moderation.Ban("user_123", 3600, "Spamming chat")
-- Ban with error handling
Moderation.Ban("user_123", 3600, "Inappropriate behavior", function(error)
if error == ModerationError.None then
print("Ban successful")
elseif error == ModerationError.InvalidUserId then
print("User ID not found")
elseif error == ModerationError.InsufficientPermissions then
print("No permission to ban")
end
end)
-- Permanent ban
Moderation.Ban("user_123", Moderation.InfiniteDuration, "Permanent ban")
Parameters
userId
durationSeconds
message
Returns
Bans a user by their user ID.
Overloads:
- Ban(userId, duration)
- Ban(userId, duration, message)
- Ban(userId, duration, message, callback)
Use Moderation.InfiniteDuration for permanent bans.
-- Ban for 1 hour (3600 seconds)
Moderation.Ban("user_123", 3600)
-- Ban with reason
Moderation.Ban("user_123", 3600, "Spamming chat")
-- Ban with error handling
Moderation.Ban("user_123", 3600, "Inappropriate behavior", function(error)
if error == ModerationError.None then
print("Ban successful")
elseif error == ModerationError.InvalidUserId then
print("User ID not found")
elseif error == ModerationError.InsufficientPermissions then
print("No permission to ban")
end
end)
-- Permanent ban
Moderation.Ban("user_123", Moderation.InfiniteDuration, "Permanent ban")
Parameters
userId
durationSeconds
message
callback
Returns
Bans a player object (convenience method that uses player.user.id).
Overloads:
- BanPlayer(player, duration)
- BanPlayer(player, duration, message)
- BanPlayer(player, duration, message, callback)
--!Type(Server)
-- Ban player for 24 hours
Moderation.BanPlayer(player, 86400, "Harassment", function(error)
if error == ModerationError.None then
print(player.name .. " has been banned for 24 hours")
end
end)
Parameters
player
durationSeconds
Returns
Bans a player object (convenience method that uses player.user.id).
Overloads:
- BanPlayer(player, duration)
- BanPlayer(player, duration, message)
- BanPlayer(player, duration, message, callback)
--!Type(Server)
-- Ban player for 24 hours
Moderation.BanPlayer(player, 86400, "Harassment", function(error)
if error == ModerationError.None then
print(player.name .. " has been banned for 24 hours")
end
end)
Parameters
Returns
Bans a player object (convenience method that uses player.user.id).
Overloads:
- BanPlayer(player, duration)
- BanPlayer(player, duration, message)
- BanPlayer(player, duration, message, callback)
--!Type(Server)
-- Ban player for 24 hours
Moderation.BanPlayer(player, 86400, "Harassment", function(error)
if error == ModerationError.None then
print(player.name .. " has been banned for 24 hours")
end
end)
Parameters
Returns
Retrieves a paginated list of banned users for this world. Use for building moderation UIs or reviewing ban history.
IMPORTANT: Rate limited. Do not call repeatedly in loops.
--!Type(Server)
-- Get first 20 banned users
Moderation.GetBannedUsers(20, nil, function(bans, cursor, error)
if error == ModerationError.None then
print("Found " .. #bans .. " banned users")
for i, ban in ipairs(bans) do
print("Banned user: " .. ban.user.name)
print(" Reason: " .. ban.message)
print(" Banned by: " .. ban.bannedBy.name)
print(" Expires at: " .. ban.expiresAt)
end
-- Get next page if cursor exists
if cursor ~= nil then
Moderation.GetBannedUsers(20, cursor, function(moreBans, nextCursor, error)
-- Handle next page
end)
end
end
end)
Parameters
limit
cursorId
callback
Returns
Kicks a user from the world immediately (does not prevent rejoin). Use Ban if you want to prevent the user from rejoining.
Overloads:
- Kick(userId)
- Kick(userId, callback)
-- Kick a user
Moderation.Kick("user_123", function(error)
if error == ModerationError.None then
print("User kicked")
end
end)
Parameters
userId
Returns
Kicks a user from the world immediately (does not prevent rejoin). Use Ban if you want to prevent the user from rejoining.
Overloads:
- Kick(userId)
- Kick(userId, callback)
-- Kick a user
Moderation.Kick("user_123", function(error)
if error == ModerationError.None then
print("User kicked")
end
end)
Parameters
userId
callback
Returns
Kicks a player from the world immediately (convenience method).
Overloads:
- KickPlayer(player)
- KickPlayer(player, callback)
--!Type(Server)
-- Kick player for rule violation
Moderation.KickPlayer(player, function(error)
if error == ModerationError.None then
print(player.name .. " has been kicked")
end
end)
Parameters
player
Returns
Kicks a player from the world immediately (convenience method).
Overloads:
- KickPlayer(player)
- KickPlayer(player, callback)
--!Type(Server)
-- Kick player for rule violation
Moderation.KickPlayer(player, function(error)
if error == ModerationError.None then
print(player.name .. " has been kicked")
end
end)
Parameters
player
callback
Returns
Mutes a user, preventing them from sending chat messages.
Overloads:
- Mute(userId, duration)
- Mute(userId, duration, callback)
Use Moderation.InfiniteDuration for permanent mutes.
-- Mute for 10 minutes
Moderation.Mute("user_123", 600, function(error)
if error == ModerationError.None then
print("User muted for 10 minutes")
end
end)
-- Permanent mute
Moderation.Mute("user_123", Moderation.InfiniteDuration)
Parameters
userId
durationSeconds
Returns
Mutes a user, preventing them from sending chat messages.
Overloads:
- Mute(userId, duration)
- Mute(userId, duration, callback)
Use Moderation.InfiniteDuration for permanent mutes.
-- Mute for 10 minutes
Moderation.Mute("user_123", 600, function(error)
if error == ModerationError.None then
print("User muted for 10 minutes")
end
end)
-- Permanent mute
Moderation.Mute("user_123", Moderation.InfiniteDuration)
Parameters
userId
durationSeconds
callback
Returns
Mutes a player (convenience method).
Overloads:
- MutePlayer(player, duration)
- MutePlayer(player, duration, callback)
--!Type(Server)
-- Mute player for spam
Moderation.MutePlayer(player, 300, function(error)
if error == ModerationError.None then
print(player.name .. " muted for 5 minutes")
end
end)
Parameters
player
durationSeconds
Returns
Mutes a player (convenience method).
Overloads:
- MutePlayer(player, duration)
- MutePlayer(player, duration, callback)
--!Type(Server)
-- Mute player for spam
Moderation.MutePlayer(player, 300, function(error)
if error == ModerationError.None then
print(player.name .. " muted for 5 minutes")
end
end)
Parameters
Returns
Removes a ban from a user by their user ID.
Overloads:
- Unban(userId)
- Unban(userId, callback)
-- Unban a user
Moderation.Unban("user_123", function(error)
if error == ModerationError.None then
print("User unbanned successfully")
end
end)
Parameters
userId
Returns
Removes a ban from a user by their user ID.
Overloads:
- Unban(userId)
- Unban(userId, callback)
-- Unban a user
Moderation.Unban("user_123", function(error)
if error == ModerationError.None then
print("User unbanned successfully")
end
end)
Parameters
userId
callback
Returns
Removes a mute from a user.
Overloads:
- Unmute(userId)
- Unmute(userId, callback)
Moderation.Unmute("user_123", function(error)
if error == ModerationError.None then
print("User unmuted")
end
end)
Parameters
userId
Returns
Removes a mute from a user.
Overloads:
- Unmute(userId)
- Unmute(userId, callback)
Moderation.Unmute("user_123", function(error)
if error == ModerationError.None then
print("User unmuted")
end
end)
Parameters
userId
callback
Returns
Removes a mute from a player (convenience method).
Overloads:
- UnmutePlayer(player)
- UnmutePlayer(player, callback)
Moderation.UnmutePlayer(player, function(error)
if error == ModerationError.None then
print(player.name .. " unmuted")
end
end)
Parameters
player
Returns
Removes a mute from a player (convenience method).
Overloads:
- UnmutePlayer(player)
- UnmutePlayer(player, callback)
Moderation.UnmutePlayer(player, function(error)
if error == ModerationError.None then
print(player.name .. " unmuted")
end
end)
Parameters
player
callback
Returns
Updated 13 days ago