How to Detect Blank Character Models

Hello! I have been trying to spawn characters by their userid sequentially starting at 1 and have noticed many of the userids are invalid and lead to deleted users. When you use CreateHumanoidModelFromDescription on these userids, it spawns a blank, grey rig. I want to know how I can detect when a model like this is created or if a userid is going to create one. Any help is appreciated!

1 Like

If you mean using Players:GetHumanoidDescriptionFromUserId,

since it returns a description, if you put an invalid ID, you check if the Description.IdleAnimation is equal to 0 (you can check other properties if you think it isn’t safe).

Here’s my test code that I used:

local Players = game:GetService("Players")
local UserId = 1

local Description = Players:GetHumanoidDescriptionFromUserId(UserId)

if Description.IdleAnimation == 0 then
	warn("grey thing")
	return
end

local Model = Players:CreateHumanoidModelFromDescription(Description, Enum.HumanoidRigType.R6, Enum.AssetTypeVerification.Default)

Model.Parent = workspace

That seems to work well with the only caveat being that in my testing some characters like John Doe and Jane Doe (ids 2 and 3 respectively) aren’t showing up despite being valid and having avatars. I did come up with a solution that doesn’t have this, however it is very slow because it uses the roblox apis. Here is my code:

function module.ValidUserID(UserID: Number): boolean
	local httpService = game:GetService("HttpService")
	local userURL: string = "https://users.roproxy.com/v1/users/" .. tostring(UserID)
	local success: boolean, result: string = pcall(function() return httpService:GetAsync(userURL) end)
	if not success then
		return false
	end
	local information = httpService:JSONDecode(result)
	return not information.isBanned
end

Maybe theres a way to speed this up?

I tried to make my own proper implementation that I’d do for the first method that I shared.

Can you please test if this works for you?

As for the API requests you cannot speed those up.

Here’s my code:

--> Services <--

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

--> Variables <--

local UserId = 2;
local Description = Players:GetHumanoidDescriptionFromUserId(UserId);

local GreyColor = Color3.fromRGB(163, 162, 165);

local BodyParts = {"HeadColor", "LeftArmColor", "RightArmColor", "LeftLegColor", "RightLegColor", "TorsoColor"};
local Animations = {"ClimbAnimation", "FallAnimation", "IdleAnimation", "JumpAnimation", "MoodAnimation", "RunAnimation", "SwimAnimation", "WalkAnimation"};

--> Functions <--

local function CheckColors(Description, Parts, Color)
	for _, Part in ipairs(Parts) do
		if Description[Part] ~= Color then
			return false;
		end;
	end;
	return true;
end;

local function CheckAnims(Description, Fields)
	for _, Field in ipairs(Fields) do
		if Description[Field] ~= 0 then
			return false;
		end;
	end;
	return true;
end;

--> Main <--

if CheckColors(Description, BodyParts, GreyColor) and CheckAnims(Description, Animations) then
	warn("grey");
	return;
end;

local Model = Players:CreateHumanoidModelFromDescription(Description, Enum.HumanoidRigType.R6, Enum.AssetTypeVerification.Default);
Model.Parent = workspace;
1 Like

That solution works well! Thank you!

1 Like

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