Checking if a user is banned through UserOwnsGamePassAsync

Hello, this is the third episode of the trilogy of terminated accounts detection methods, preceded by:

In this episode we check if a user is banned or not through the UserOwnsGamePassAsync function of MarketplaceService. More specifically based on if it errors or not, and if the error is specifically The specified user does not exist! which is given for banned/terminated accounts and accounts that no yet exist(for example user ids above 10 billion). The main negative of this method is that as I just mentioned, if a userId passed in it doesn’t exist yet(because it’s too big), it will mark it as banned.

Anyways the code for this one is really simple:

local function isBanned(userId: number): boolean
	local success, response = pcall(function()
		return game.MarketplaceService:UserOwnsGamePassAsync(userId, 1)
	end)
	if success then return false end
	--this error text may change on future Roblox update
	--if only we had a proper way to detect specific errors
	if response == "The specified user does not exist!" then return true end
	--in case another error happens so you can handle it in a pcall
	error(response)
end
5 Likes