How to ban a player via the console using BanAsync?

Hello! I’m wanting to know if there’s a way to ban players using the new BanAsync using the Roblox Developer Console. Thanks!

You just have to specify the name, all required fields, and any optional fields. The entire snippet can be pasted into the console.

local Players = game:GetService("Players")

Players:BanAsync({
	UserIds = {Players["PLAYER_NAME"].UserId},
	Duration = 3600,
	DisplayReason = "You know what you did.",
	PrivateReason = "Lollygagging"
})
1 Like

You should be checking the documentation.

From the wiki:

local Players = game:GetService("Players")

if shouldBeBanned(player: Player) then
	local banHistoryPages = Players:GetBanHistoryAsync(player.UserId)
	local duration = getNextBanDuration(banHistoryPages)  -- Creator-implemented logic
	local config: BanConfigType = {
		UserIds = {player.UserId},
		Duration = duration,
		DisplayReason = "You violated community guideline #5",
		PrivateReason = "Put anything here that the user should not know but is helpful for your records",
		ExcludeAltAccounts = false,
		ApplyToUniverse = true
	}

	local success, err = pcall(function()
		return Players:BanAsync(config)
	end)
	print(success, err)
end
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.