Shoulder Accessory Position Incorrect

I made a script that changes an NPC’s appearance using Humanoid:ApplyDescription(). When played, the NPC’s shoulder accessory is in the wrong position. How can I fix this so that the accessory’s position is on the shoulder?
Screen Shot 2021-06-04 at 9.20.42 PM

1 Like

As this is scripting support you should show us the script you are using.
You may wish to add some prints in to confirm the position and orientation of the accessory is as you expect and if not take the option to adjust it.

Here is the script:

local ReplicatedStorage=game:GetService("ReplicatedStorage")
local playerid=ReplicatedStorage:WaitForChild("PlayerId")
local npc=script.Parent:WaitForChild("Humanoid")

playerid.OnServerEvent:Connect(function(player)
print(player.UserId)
npc:ApplyDescription(game.Players:GetHumanoidDescriptionFromUserId(player.UserId))
end)

local script gets the localplayer’s id

local players=game:GetService("Players").LocalPlayer
local ReplicatedStorage=game:GetService("ReplicatedStorage")
local playerid=ReplicatedStorage:WaitForChild("PlayerId")
local player=players.UserId

playerid:FireServer(player)
2 Likes

Ok, thanks for showing the script.
When you run this in Studio can you manually adjust the accessory position and rotation using the Studio tools? ​
If so can you make a note of the correct values and then apply them in the script after the Apply?

1 Like

Yes, I can adjust the accessory position, but only when the character’s HumanoidRootPart is anchored. I also found out that the accessory’s handle has a weld attached to the head.

When the HumanoidRootPart is unanchored and I position the accessory, it falls, as the weld is destroyed.

I made a script to try and apply the correct values, but it doesn’t seem to work.

local ReplicatedStorage=game:GetService("ReplicatedStorage")
local playerid=ReplicatedStorage:WaitForChild("PlayerId")
local npc=script.Parent:WaitForChild("Humanoid")
local head=script.Parent.Head


playerid.OnServerEvent:Connect(function(player)
	print(player.UserId)
	npc:ApplyDescription(game.Players:GetHumanoidDescriptionFromUserId(player.UserId))
	wait(1)
	
	local accessory=script.Parent:FindFirstChildOfClass("Accessory"):WaitForChild("Handle")
	local weld=script.Parent.Head:FindFirstChildOfClass("Weld")
	
	weld:Destroy()
	accessory.Position=Vector3.new(26.3, 4.46, 36.85)
	local newweld=Instance.new("Weld")
	newweld.Parent=head
	newweld.Part0=head
	newweld.Part1=accessory
end)

The thing is, I want the shoulder accessories to be correct for all players whose appearance is applied to the dummy.

Do you have an attachment object present in the Handle of the accessory? If not, you need to create one with the name of the shoulder attachment. Same-named attachments will snap together when you add an accessory to the character so if you have the appropriate name then it’ll automatically handle positioning for you. You’d just need to change the position of the attachment, no code needed.

3 Likes

This is a bug with HumanoidDescriptions. In games like Work At a Pizza Place this happens to the NPCs ordering pizza, and it happens a lot to caps in that game going over the NPCs head.

1 Like

He said he made a script that automatically changes an NPC appearance, he would need code to fix the issue.

1 Like

No, I disagree wholeheartedly. I work with accessories and you don’t need code to correct the position of a shoulder accessory. Please read up on how accessories work.

Here I have a simple 1x1x1 block that will become a properly-positioned shoulder accessory:

Did not write any code for that and it appears on my shoulder. It’s not a bug, it’s a matter of incorrectly using HumanoidDescriptions or improperly setting up accessories.

1 Like

This affects mostly R6 in my experience because HumanoidDescriptions will only load the attachments for R15. It is even R6 in his screenshots.

1 Like

R6 does not have this problem either as R6 has a shoulder attachment in each arm.

1 Like

All of the times this has happened was when he was using NPCs, the example I stated was of an NPC
Here is a screenshot applying the outfit of one of my old accounts onto a studio dummy


And here it is on an R6 player character next to the NPC dummy

(Ignore the head, I just didn’t add a mesh)

Both applied the same way with the studio command bar

1 Like

If you’re generating an NPC from the built-in rig builder it doesn’t come with the current set of attachments native to R6 rigs (this is bad design and feature requests have been filed to correct this). As there’s no attachment to snap to, it just picks the center of the head as the default snap point.

Still not a problem with R6 rigs though, regardless of if it’s an NPC or not. Add the attachments in by hand and then use that dummy with attachments in it as your template rig rather than doing fresh generations every time and then it’s no longer a problem. The issue still lies in the fact that the environment is not properly set up. It’s not an issue with the instances involved and it most certainly isn’t a bug either.

If you really need to programmatically resolve this because for whatever reason you’re unable to add in the attachments by hand or want an automated solution, you can do that too. Any addition of a shoulder attachment will instantly fix the problem (assuming the attachment in the handle’s accessory is of the same name) without need to modify anything else.

local rightShoulderAttachment = Instance.new("Attachment")
rightShoulderAttachment.Name = "RightShoulderAttachment"
rightShoulderAttachment.Position = Vector3.new(0, 1, 0)

-- Cloning the RSA also works and just changing the name
-- Attachment positions are relative
local leftShoulderAttachment = Instance.new("Attachment")
leftShoulderAttachment.Name = "LeftShoulderAttachment"
leftShoulderAttachment.Position = Vector3.new(0, 1, 0)

rightShoulderAttachment.Parent = Character["Right Arm"]
leftShoulderAttachment.Parent = Character["Left Arm"]

Again though, you don’t need code for this because this is an issue strictly born out of generating rigs from the default rig builder plugin which does not host the most updated R6 rigs.

2 Likes

Is there a way to tell the difference between different types of accessories in the script? (ex. Hats, Waist, Shoulders, etc.)

You mean for example in my picture how you can tell if Accessory (the brick) is a shoulder accessory or not? Roblox does not include any method for this natively so you’d have to write some code for that.

Accessory types would have to be hardcoded into a list of names that you can fetch out… It’s pretty time consuming and annoying to write out, especially because of UGC - sometimes an accessory you’d expect to be one way is actually another way or using an attachment you don’t expect.

For the sake of reference, what’s your use case for attempting to differentiate between accessories?

1 Like

Was thinking about categorizing different types of accessories, but then I realized you could use the name of the attachments from the accessory to do so. :sweat_smile:

I’m sorry for reviving this, but this doesn’t seem to work (both of the attachments have the same position):
image
And this still happens when I paste/duplicate it (left character is how it should look, and right is what it looks like), I talk more about this in this topic:
image

Thank you for replying!

Attachments snap in relative position so they shouldn’t have the same position. RightShoulderAttachment in the RightUpperArm should remain in its original position and RightShoulderAttachment in the accessory’s handle should be where you want it to “attach”.

Both parts need to be unanchored.

It may be helpful to supply a repro file (not your actual project files but a place where you can reproduce the issue) if you are still having trouble with positioning accessories in this way.

EDIT: A word for clarity.

2 Likes

Even though I do that and set their respective positions it still doesn’t work.

I don’t think attachments are anchorables (at least I didn’t find any related property).

It actually only happens in a specific place (the one I’m working on, and it is my main and only project). It seems to work perfectly in other places I recently created for testing, what can cause this issue?

Thank you for replying!

By “both need to be unanchored” I was referring to the parts not the attachments - didn’t intend for that to be taken literally as “attachments need to be unanchored” (they’re not physical entities to begin with), so I apologise if the wording confused you there.

If this issue is place-specific then likewise the resolution is place-specific. This is something you will have to investigate on your own up to reconstructing the rig or building it in a different place and transferring it over. Any number of oversights can influence this and I have no details so the best I can tell you is to just look over your place file or be more careful in constructing your rigs.

2 Likes