How to check if a user is banned through httpRequest and if banned, skip queue

Hello everyone,
currently I am making an Outfit Loader game, but there seems to be a bug which makes the queue get stuck (Bad Request 400) as soon as a banned user gets requested.
I am trying to check if the string returned by the API is the error/banned string and if it is that it skips the queue for that user.

The error string (on the API) I get when the user is banned is:

{"errors":[{"code":1,"message":"The specified user does not exist.","userFacingMessage":"Something went wrong","field":"userId","fieldData":6}]}

But when I click on the 400 in the console (when I enter a banned user), it redirects me to the local script in the request button:
err1

This is the server sided script:

-- not needed anymore

I already tried running a check in a local script which will call a remote event which skips the queue but it does not seem to work.

Does anyone have an idea what I can still can try?

You can send a request when the server is invoked, before adding the player to the queue to check whether the player is banned, here is some code using the ROBLOX API:

local isBanned = function(UserID)
      return game:GetService("HttpService"):JSONDecode(game:GetService("HttpService"):GetAsync("https://users.roproxy.com/v1/users/" .. shared.userId))['isBanned']
end

if isBanned(shared.userId) == false then
   -- User is not banned
end
2 Likes

Do I have to put this into the serversided script or local script? When I try to put it in the local script, it returns an error (…Request.LocalScript:26: attempt to concatenate string with nil).

You can only use HttpService On the server.

Oh yea right. I will try to insert it in the ServerSided script then

Could you maybe refer more into how to check if isBanned = true after JSONDecode so I can instantly run a function?

All you need to do is insert the function anywhere in your script, and then call the function when checking a user, after you get their user ID as shown in the example.

if isBanned(shared.userId) == false then
   -- User is not banned
end
1 Like

Ohhh… Thanks! It was actually way simplier. Just like you coded. I thought I still had to add something, but nope! Thanks!

There might still be a problem. I do not know what causes this, but when I try to run a check if isBanned == true and then print(“abc”), it does not print anything and just errors Bad Request 400 in the console. For isBanned == false, the checks work.

This is the code that runs the checks:

--BanCheck Function
local isBanned = function(BanCheck)
	return game:GetService("HttpService"):JSONDecode(game:GetService("HttpService"):GetAsync("https://users.roproxy.com/v1/users/" .. shared.userId))['isBanned']
end



local checkPlayer = function()
	if #requests >= 1 then
		local userId = (requests[1])
		local data = httpService:JSONDecode(httpService:GetAsync(shared.baseUrl1..userId..shared.baseUrl2))
		
		if data then

			isBanned()
			if isBanned(userId) == false then
				print("123")
			elseif isBanned(userId) == true then
				print("abc")
				_G.PlayerNameText.Text = "User Terminated / Error"
				_G.QueueScroll:FindFirstChild("1"):Destroy()
				_G.Items = 0
				shared.IsOnRequests = false
				task.wait(5)
			end
		end

Remove the random isBanned() from the top of the check.