How to Validate HumanoidDescription for terminated users?

I have a game which pulls random friends from your friends list and makes them NPCs. There is an issue where terminated users do not load in properly. However, it does not throw an error so even using a pcall does not work. The Humanoid is just entirely unchanged.

	local id = 12345 -- assume a TERMINATED user id!

	local success = pcall(function()
		local newHumanoidDescription = game.Players:GetHumanoidDescriptionFromUserId(id)
		dummy.Humanoid:ApplyDescription(newHumanoidDescription)
	end)

How can I validate for this? It’d be an issue if NPCs are just sometimes blank. My intention is to reroll them if it’s a terminated user.

Hey, you can use GetCharacterAppearanceFromUserId and use pcall with it to determine if user is terminated or not, it returns error 400 if user terminated, if user is not terminated, GetCharacterAppearanceFromUserId returns table, here’s example code :slight_smile:

local terminated_userid = 8166491 -- // random terminated user id
local normal_userid = 1
-- // returns true if terminated.
local function isUserTerminated(userid : number) : boolean
	local success,err
	success,err = pcall(function()
		game:GetService('Players'):GetCharacterAppearanceInfoAsync(userid)
	end)
	return not success
end

print(isUserTerminated(terminated_userid)) 
print(isUserTerminated(normal_userid)) 

Please mark as solved if it worked for you, i appreciate it :slight_smile:

1 Like

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