Negative HipHeight Issue with :BuildRigFromAttachments

Hello,

I’m currently working on an NPC system where NPCs are minimally represented on the server-side (only a Humanoid and HumanoidRootPart), with the remaining visual elements rendered on the client-side. My implementation utilizes the :BuildRigFromAttachments function.

Unfortunately, I’m running into an issue where the function is causing the NPCs’ Humanoid HipHeight to be -1, which results in the NPCs appearing partially submerged into the ground. I have been unable to identify the cause of this issue.

Here’s a brief snippet of my code which is executed on the client:

local model = workspace.Rig
local humanoid = model.Humanoid

local rootRigAttachment = Instance.new("Attachment")
rootRigAttachment.Parent = model.HumanoidRootPart
rootRigAttachment.Name = "RootRigAttachment"

local baseRig = workspace.R6
for _, limb in pairs(baseRig:GetChildren()) do
	local limbClone = limb:Clone()
	limbClone.Parent = model
end
humanoid:BuildRigFromAttachments()

My efforts to solve this issue have involved searching the Developer Hub and attempting to rotate the attachments, but neither of these have resolved my issue. It seems there is little discussion or documentation on :BuildRigFromAttachments causing this particular problem.

Please feel free to review it:
TestPlace.rbxl (49.9 KB)

Any guidance or insight into this issue would be greatly appreciated.

Thank you for your time.

Have a look in the Humanoid in the game during testing to see where the actual Attachment is located. That might help you determine what’s going on.

During testing go to the Model tab, select the NPC, and click the Show Constraints button and it’ll point out where the Attachment is. Or you can select the Attachment in the NPC with the Move tool and it’ll show you the move tool handles to indicate where the Attachment is.

Hello,

The attachments are located exactly where they should be located.
They have not moved.
However, I have never used :BuildRigFromAttachments therefore I do not know if they are positioned correctly.

Yes, but you are putting in an Attachment without setting the Attachment’s Position. If you don’t it’s going to be placed at 0,0,0 in the HumanoidRootPart.
I’m just guessing now, but if BuildRigFromAttachments uses that Attachment as the bottom of the rig then it’ll place the HumanoidRootPart at the ground in game.

Is your game set to support R6 and R15, or just one of them?

I need it to be at 0, 0, 0, since that’s where the Torso is going to be.
I only support R6, and you can always see for yourself.
I have provided the place file.

If you set the HipHeight it works, but not until your player gets closer to the NPC. After about 30 seconds then the NPC pops up.
I think it has to do with the way you’ve got it set up.
I put the R6 model into ReplicatedStorage, turned the LocalScript into a Script, and set the HipHeight in the script.
Now the Humanoid stands up.

local model = workspace.Rig
local humanoid = model.Humanoid

local rootRigAttachment = Instance.new("Attachment")
rootRigAttachment.Parent = model.HumanoidRootPart
rootRigAttachment.Name = "RootRigAttachment"

local baseRig = workspace.R6
for _, limb in pairs(baseRig:GetChildren()) do
	local limbClone = limb:Clone()
	limbClone.Parent = model
end
humanoid:BuildRigFromAttachments()
humanoid.HipHeight = 0

Here’s your place with the changes I made:
TestPlace.rbxl (49.9 KB)

Also, thanks for getting me to learn about ReplicatedStorage!

Thank you for your answer, but if you read the post.
I need to render the NPC on the client, therefore I cannot put this code into a server script.

I got it to work:

  1. Anchored all the parts for the R6.
  2. Anchored the HumanoidRootPart for the Rig.
  3. Set the HumanoidRootPart Y Position to be 3 studs (for your Rig)

Then made a few minor changes to the script:

local model = workspace.Rig
local humanoid = model.Humanoid

local rootRigAttachment = Instance.new("Attachment")
rootRigAttachment.Parent = model.HumanoidRootPart
rootRigAttachment.Name = "RootRigAttachment"

local baseRig = workspace.R6
for _, limb in pairs(baseRig:GetChildren()) do
	local limbClone = limb:Clone()
	limbClone.Parent = model
	limbClone.Anchored = false -- added
end

humanoid:BuildRigFromAttachments()

-- ADDED
wait(1)
humanoid.HipHeight = 0
model.HumanoidRootPart.Anchored = false

Ah, k.
When I added the humanoid.HipHeight = 0 it worked with the way you originally had it setup, but like I said, it took 20-30 seconds for it to stand up when the player was away from it.
Before that when the player walked close the NPC would rise up, but would sink again when the player walked away. After that time the NPC stayed at it’s proper height above the baseplate.