Introducing the Ban API and Alt Account Detection

I think an API like this is great, I’ve been waiting for it for months :pray:

1 Like

FINNALY… Im so exited to have this being implemented into games to remove annoying alts. Thanks Roblox!

1 Like

That’s exactly the cool option I ment, you can provide ExcludeAltAccounts and set it to true or false!

1 Like

Great addition, excited to implement.

1 Like

I am super excited for this to be added! I have been advocating for a feature like this for quite a while, and I love to see it be implemented!

1 Like

Why is the ban reason subjected to text filter? It makes no sense to me when you can put anything you want in the kick reason, as well as for practically anything else in the game. If the reason is supplied dynamically by moderators, that should be developer’s responsibility to filter the text before feeding it into the ban async function.

Also, I don’t see any way to remove ban record from the ban history, I think it would be nice to be able to remove it for false bans, or bans made when testing live.

It should be like this:

--!strict

local Players = game:GetService("Players")
local TextService = game:GetService("TextService")

local function filterTextForUserAsync(
	text: string,
	senderId: number,
	receiverId: number,
	context: Enum.TextFilterContext
): string?
	-- Prepare the text filter
	local textFilterObj: TextFilterResult? = nil

	local success, err = pcall(function()
		textFilterObj = TextService:FilterStringAsync(text, senderId, context)
	end)

	if not textFilterObj or err then
		return
	end

	-- Filter the text
	local filteredText: string? = nil

	local success, err = pcall(function()
		filteredText = textFilterObj:GetNonChatStringForUserAsync(receiverId)
	end)

	if not filteredText or err then
		return
	end
	
	return filteredText
end

-- There is a reason to filter text here since the reason is supplied dynamically
-- by approved moderators in the game, but since you are not willing to take responsibility
-- for their ban reasons, you will properly filter it via Roblox provided text filter API
local function banUserViaAdminPanel(
	targetUserId: number,
	moderatorUserId: number,
	moderatorSuppliedReason: string,
	moderatorSuppliedDuration: number
): (boolean, string)
	local filteredModeratorSuppliedReason = filterTextForUserAsync(
		moderatorSuppliedReason,
		moderatorUserId,
		targetUserId,
		Enum.TextFilterContext.PrivateChat
	)
	
	if not filteredModeratorSuppliedReason then
		return false, "Supplied reason was either filtered or failed to filter"
	end
	
	local success, err = pcall(function()
		Players:BanAsync({
			UserIds = {targetUserId},
			ApplyToUniverse = true,
			Duration = moderatorSuppliedDuration,
			DisplayReason = filteredModeratorSuppliedReason,
			PrivateReason = "They misbehaved",
			ExcludeAltAccounts = false
		})
	end)
	
	if err then
		return false, "An error occured when attempted to ban the user"
	end
	
	return true, "User was banned successfully"
end

-- There is no reason to filter text here since the reason is hardcoded
-- this is true for any piece of text that you have control over,
-- and willing to take responsibility for it
local function automaticBan(targetUserId: number): ()
	local success, err = pcall(function()
		Players:BanAsync({
			UserIds = {targetUserId},
			ApplyToUniverse = true,
			Duration = -1,
			DisplayReason = "Some good reason that should not be filtered",
			PrivateReason = "Whatever you want here",
			ExcludeAltAccounts = false
		})
	end)

	if success then
		-- Successfully banned the player
	end
end

Also, shouldn’t ExcludeAltAccounts be IncludeAltAccounts based on the language used in other places? In the past Roblox had Disabled property but it was replaced with Enabled.

8 Likes

Hooray! Finally, I really waited for something like hardware ban. Thanks to engeneering team for implementing this feature!

2 Likes

I typed 15 minutes but ok…

image

1 minutes?? :thinking:

:sob:

1 Like

I made an update to the default script :slight_smile:

local Players = game:GetService("Players")

-- Example function to determine if a player should be banned
local function shouldBeBanned(player)
    -- Implement your ban logic here
    return true  -- Replace with your actual logic
end

-- Example function to calculate ban duration based on ban history
local function getNextBanDuration(banHistoryPages)
    -- Implement your logic to calculate ban duration based on ban history
    return 3600  -- Replace with your actual logic (e.g., check ban count, severity, etc.)
end

-- Example usage of banning a player
local function banPlayer(player)
    if shouldBeBanned(player) then
        local banHistoryPages = Players:GetBanHistoryAsync(player.UserId)
        local duration = getNextBanDuration(banHistoryPages)

        local config = {
            UserIds = {player.UserId},
            Duration = duration,
            DisplayReason = "You violated community guideline #5",
            PrivateReason = "Exploiting + insult",
            ExcludeAltAccounts = false,
            ApplyToUniverse = true
        }

        local success, err = pcall(function()
            Players:BanAsync(config)
        end)

        if not success then
            warn("Failed to ban player:", err)
        else
            print("Player banned successfully")
        end
    else
        print("Player should not be banned")
    end
end

-- Example: Connect to PlayerAdded event to monitor new players
Players.PlayerAdded:Connect(function(player)
    -- Example: Wait for 5 seconds before checking if the player should be banned
    wait(5)

    -- Example: Call the ban function
    banPlayer(player)
end)
1 Like

It goes off seconds, so if you typed 15 you prob banned yourself for 15 seconds not minutes.

I banned myself and I can’t unban myself. :thinking:

Time to explore the API, I thought there’s a Ban History UI

Will the APIs will be enabled in Studio or will there be an alternative way to unban users? Encountered an issue where my account would be banned in a production environment and not able to unban from a studio one. Also, with the alt account detection making it impossible to join on an alt to unban the user this would be extremely helpful.

Unless I’ve missed something, the only workaround at present seems to be unbanning via the Open Cloud API.

image

2 Likes

I think it’d be helpful if the ban message was actually shown on the experience details page for the user. Right now there’s no indication that you’re banned, not even the play button is disabled.



Also, you shouldn’t be able to downvote an experience if you’re banned from it. I was really hoping that banning a user would prevent that.

Previous systems of immediately kicking users to prevent them from joining was never a good solution because they will just downvote the game. And if you were around on Roblox long enough to remember Personal Building Servers, they’d always get spammed with unfair downvotes from griefers getting banned.

10 Likes

Exploiters are absolutely COOKED.

2 Likes

This is how it works ingame if anyone is interested. (third one is alt detection ban)



3 Likes

ALT detection doesn’t seem to work for me (new account & account switcher), I assume this is in some sort of tracking mode and will be activated soon?

What steps did you take to get to your ALT?

1 Like

Exactly one day after me publishing my ban module.
When the banning API was announced at RDC, I put my ban module on hold but since it never came, I have now completed it.
Great timing :sweat_smile:

image

Would be nice if the ban reason was on the game’s page instead of appearing after they join the game:
image

29 Likes

14 years too late but im glad to see it, this is gonna be a banger for people that dont want to put kohls admin in and have minimal scripting knowledge.

2 Likes

holy moly, amazing update. I was so excited for this back in February. Ban API and hopefully a new UI update this month? Roblox is crazyy

1 Like