How can I check to see if the player is terminated using a userId?
Using roblox’s web API, you can send a GET request to https://users.roblox.com/v1/users/{userId} where {userId} is where the user’s userId goes. (See endpoint documentation)
The API endpoint provides a JSON string that needs to be JSON decoded and it provides an entry in the table with an index of IsBanned
and a boolean as a value (if true, the user is banned, false if otherwise)
We can’t send requests to roblox domain from studio nor the player client, so you can use http://rprxy.xyz or your own dedicated proxy server:
local ID = 1
local http = game:GetService("HttpService")
local url = ("https://users.rprxy.xyz/v1/users/%d"):format(ID)
local result = http:JSONDecode(http:GetAsync(url))
print(result.isBanned)
it works for the most part but eventually returns a 404 error, why is that?
You can get error 404 if you used the wrong url or the ID you used doesn’t exist or it does not belong to a player. You can try implementing a retry procedure if the request failed (due to 404 or 429 – sending too many requests to the endpoint) to resend the request a few seconds later:
function send(ID, tries)
tries = tries or 0
local success, response = pcall(function()
local http = game:GetService("HttpService")
local url = ("https://users.rprxy.xyz/v1/users/%d"):format(ID)
local result = http:JSONDecode(http:GetAsync(url))
return result.isBanned
end)
if not success and tries < 5 then
tries += 1
task.wait(3)
return send(ID, tries)
elseif success then
return response
elseif not success and tries >= 5 then
return "Couldn't get termination status"
end
end
local isBanned = send(1)
I know this topic may be around 3 years old, but I have an alternative to this, using a service called UserService, which is mainly used to retrieve info (such as it’s display name, has verified badge) for each listed userId without the use of HTTP requests.
How this works is by the table it returns, so it appears if you were to fetch info with a user Id for a user whose terminated, the table would return as empty, here’s an example of the script:
local UserService = game:GetService("UserService")
local Plrs = game.Players
local UserId = 2000
local Success, Info = pcall(function()
return UserService:GetUserInfosByUserIdsAsync({UserId})
end)
if Success then
local UserExists = pcall(function()
Plrs:GetNameFromUserIdAsync(UserId)
end)
if UserExists and #Info == 0 then
print("User is terminated!")
elseif UserExists then
print("User is standing!")
else
print("User does not exist!")
end
else
warn(Info)
end