How to check (with a script) if the avatar has the default body parts or different ones? (IMAGES)

Hello, i was wondering how to check (with a script) if the avatar has the default body parts or different ones?



Green parts are the ones with the default body parts, red ones the ones with different body parts

1 Like

You can use the method Players:GetHumanoidDescriptionFromUserId() which will return a HumanoidDescription, using that you can check the AssetID of each limb and if the AssetID returned is 0 that means they are using the default blocky avatar.

You can use the HumanoidDescription to obtain the AssetID of each limb.

1 Like

I got so invested in this that I just created an entire module for it, this is how to use it:

--Script in starter character scripts so script.Parent = character
--If you want to run this on the client, you must import the module from the marketplace and use path instead
local defaults = require(14183984635)(script.Parent)

if defaults then
	for part, isDefault in pairs(defaults) do
		print(part.Name, "=", isDefault)
	end
else
	print("Character doesn't have a humanoid or isn't R6/R15")
end

The module returns a boolean dictionary where the keys are the character body parts and the values are true if the part is default and false if not. My module doesn’t use GetHumanoidDescription and thus it can run for in-game avatars and NPCS as well(as long they’re valid humanoids).

Basically for your use case after fetching the result you do something like:

for part, isDefault in pairs(defaults) do
	if isDefault then
		--color the part green
	else
		--color the part red
	end
end
2 Likes

Thanks for the help, it worked well, but do you know how to implement that in this custom rig script? cause i want it to only load on body parts that are the accepted ones (Blocky) and leave the other non-accepted body parts unchanged

-- Load Deformation Rig.
-- Remember this is not a proper script (it's an example) and there's better ways to implement this.
-- @Dogutsune, 2020

local LOAD_TIME = 8 -- How long we're going to wait for that appearance.
local DEFAULT_BODY_ASSETID = 0
local ACCEPTED_TORSO_ID = 48474356 -- AssetID of the accepted torso (girl torso).

local players = game:GetService("Players")
local rig = game.ServerStorage.Dogu15Deform

local function IsDefaultAvatar(humanoidDescription)
	-- Check if all the body part AssetIDs are equal to the default body AssetID.
	return humanoidDescription.Head == DEFAULT_BODY_ASSETID
		and (humanoidDescription.Torso == DEFAULT_BODY_ASSETID or humanoidDescription.Torso == ACCEPTED_TORSO_ID)
		and humanoidDescription.LeftArm == DEFAULT_BODY_ASSETID
		and humanoidDescription.RightArm == DEFAULT_BODY_ASSETID
		and humanoidDescription.LeftLeg == DEFAULT_BODY_ASSETID
		and humanoidDescription.RightLeg == DEFAULT_BODY_ASSETID
end

local function Update(character)
	local humanoid = character:FindFirstChildOfClass("Humanoid")
	if not humanoid or humanoid.Health <= 0 then return end

	local player = players:GetPlayerFromCharacter(character)
	if player then
		local humanoidDescription = players:GetHumanoidDescriptionFromUserId(player.UserId)
		if not humanoidDescription or not IsDefaultAvatar(humanoidDescription) then
			print("[Dogu15] "..player.Name.." - CharacterAppearance didn't load (not default avatar).")
			return
		end
	end

	humanoid:UnequipTools() 
	for _, part in pairs(rig:GetDescendants()) do
		if part:IsA("BasePart") then
			humanoid:ReplaceBodyPartR15(part.Name, part:Clone())
		end
	end
	print("[Dogu15] "..player.Name.." - CharacterAppearance loaded successfully.")
end

-- For players.
local function PlayerJoined(player)
	-- CharacterAppearanceLoaded was a mistake.
	-- I'M LOOKING AT YOU, RANDOM AVATAR SERVICE OUTAGE WHICH HAPPENED DURING TESTS.
	player.CharacterAdded:Connect(function(character)
		local success = false
		if not player.HasAppearanceLoaded then
			local timer = 0
			repeat
				if player.HasAppearanceLoaded then
					success = true
					break
				end
				local t = wait(.1)
				timer += t
			until timer >= LOAD_TIME
		else
			success = true
		end
		task.delay(.1, Update, character) -- Slight delay.
	end)
end

players.PlayerAdded:Connect(PlayerJoined)

--[[ For NPCs. I use this to update chars with a new version of the rig ;)
local a = workspace.AnimatedChars
for _, model in pairs(a:GetChildren()) do
	Update(model)
end
]]

I’m glad to see I helped. Make sure to mark it as a solution. :slight_smile:

As for your other question, are you wanting it not to modify the non-blocky body parts?
If so, you need to delete the for loop at the end of the “Update” function as it seems to be the part changing non-blocky parts.

Hi, tried doing that but it completely disables the rig if a non-accepted body part is used

What exactly are you wanting to happen? I’m a bit confused

I’m trying to edit the script so it only loads the deform rig for the DEFAULT_BODY_ASSETID body parts, while leaving the other non - DEFAULT_BODY_ASSETID body parts without the rig

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