Assistance with Local ApplyDescription

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? I’m trying to make it so a Dummy in a ViewportFrame has a Humanoid that’s created locally, and then has the Players Humanoid Description.

  2. What is the issue? I’m making a new Humanoid, however, it’s not setting the right assets with ApplyDescription.

  3. What solutions have you tried so far? I’ve looked both on the DevForums, and the API Reference for Humanoids. I’ve seen things such as it can only work if the Humanoid is made locally, which it is. Please see below for the code.

local Humanoid = game.Players.LocalPlayer.Character.Humanoid
local CurrentDescription = Humanoid:GetAppliedDescription()
local Newhumanoid = Instance.new(Humanoid, game.Players.LocalPlayer.PlayerGui.IntroNew.Background.Customization.Player.WorldModel.Dummy)
CurrentDescription.Head = 0
CurrentDescription.Torso = 0
CurrentDescription.LeftArm = 0
CurrentDescription.RightArm = 0
CurrentDescription.LeftLeg = 0
CurrentDescription.RightLeg = 0
Newhumanoid:ApplyDescription(CurrentDescription)

Hey James,

If I understand your problem correctly, you are trying to display the character’s avatar in the display port. If this is the case, I would like to describe why your code is not working and I would like to improve your code as a whole.

Firstly, your code is not working as you are setting limbs of the CurrentDescription to have an assetID of 0. In addition to this, Roblox does not allow you to apply a description to a humanoid on the client like you are trying to do. This means that you will have to spawn in a new character on the client using Players:CreateHumanoidModelFromDescription. I have provided sample code below, but please note that this solution will still take a bit of work to fully accomplish. We’re here to guide you and help you if you need further assistance.

Secondly, please read up on this article. Not only is it a good read, it also contains some valuable information that you may benefit from.

--Sample code intended to be used within a localScript.
local player = game.Players.LocalPlayer
local id = game:GetService("Players"):GetUserIdFromNameAsync(player.Name)
local char = player.Character
local myHum = char:FindFirstChild("Humanoid")

local function positionCharacter(rig : Model)
	--TODO: CFrame the humanoidRootPart so that it appears in the viewportFrame 
	local humanoidRootPart = rig:FindFirstChild("HumanoidRootPart")
end

local function createCharacter(desc : HumanoidDescription) : Model
	local rig = game.Players:CreateHumanoidModelFromDescription(desc, Enum.HumanoidRigType.R15)
	positionCharacter(rig)
	rig.Parent = game.Workspace
	return rig
end

local function getDesc(id : number) : HumanoidDescription
	return game.Players:GetHumanoidDescriptionFromUserId(id)
end

--TODO: Wrap the below code in a function
local desc = getDesc(id)
local viewportChar = createCharacter(desc)

If you have any questions, feel free to ask them below,
Bees

Hi! Apologies, I should have clarified in the original post. The cloning works, as does the parenting to the ViewportFrame however, the problem is updating the Dummy’s Shirt and Pants. The Hair will apply, and the head will change to the Player’s skin color, but the rest won’t. I’ll definitely go through and edit (a lot :grimacing:) of Instance Parenting I have, so thanks for that information! As for setting the body parts to 0, my game is meant to run with the default blocky package, which as far as I know is just the BodyParts being set to 0. Any further help would be greatly appreciated! Attached are pictures showing that the Dummy is being updated, just not sure why the clothes and Skin Color won’t change. (I also made sure I was using the correct Shirt/Pants texture ^^)


image

Edit: Your code did work but if I were to try and update either the BodyParts, or the Shirt/Pants I’m not entirely sure where I’d need to put that :sweat_smile::sweat_smile:

-- assuming you have a reference to the ViewportFrame and the player's character model
local viewportFrame = ... -- replace with your ViewportFrame reference
local playerCharacter = ... -- replace with your player's character model reference

-- create a new humanoid character
local humanoid = Instance.new("Humanoid")
humanoid.Parent = viewportFrame

-- get the player's humanoid description
local humanoidDescription = playerCharacter.Humanoid:GetAppliedDescription()

-- apply the description to the new humanoid
humanoid:ApplyDescription(humanoidDescription)

I ended up finding a hacky way to get it to work, gonna go ahead and mark this as the solution. Thanks to both of you for the help! :slight_smile:

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