BanService¶
Inherits Instance
BanService lets a game server ban and unban players by their account. Bans are stored on the platform per game, so they persist across server restarts and rejoins. Banning calls only take effect on the server.
Example usage:
-- Get the service (this only works in a server script)
local BanService = game["BanService"]
-- Permanently ban a player
BanService:BanPlayer(player, "Cheating")
-- Ban for one hour (3600 seconds)
BanService:BanPlayer(player, "Spamming", 3600)
-- Ban someone by their user id, even if they are not in the game
BanService:BanUserId(59, "Cheating")
-- Lift a ban
BanService:UnbanPlayer(player)
Static Class
This object is a static class. It can be accessed like this: BanService.
Additionally, it cannot be created in the creator menu or with Instance.New().
Not newable
This object cannot be created by scripts using Instance.New().
Methods¶
BanPlayer → nil¶
Bans the player and kicks them. Pass a positive durationSeconds for a temporary ban, or omit it (or use -1) for a permanent ban. Server only.
UnbanPlayer → nil¶
Parameters: player [ Player ]
Removes an active ban for the player. Server only.
IsBanned → boolean¶
Parameters: player [ Player ]
Returns true if the player currently has an active ban for this game.
BanUserId → nil¶
Parameters
userId [ number ]
reason [ string ]
durationSeconds [ number? ]
Bans a user by their account ID, even if they are not currently in the game. If they are online they get kicked too. Use a positive durationSeconds for a temporary ban, or omit it for a permanent ban. Server only.
UnbanUserId → nil¶
Parameters: userId [ number ]
Removes an active ban for the given user ID. Server only.
IsUserIdBanned → boolean¶
Parameters: userId [ number ]
Returns true if the given user ID currently has an active ban for this game.