NPC Head sometimes attached to his side

  1. What do you want to achieve?
    Stop this occasional glitch.

  2. What is the issue?
    When I spawn the NPC fairly quickly with a hat attached, sometimes the head will change the neck attachment to attach via the hat attachment to the back point and it will stick out side.

  3. What solutions have you tried so far?
    Checking the code but most of the time it’s working fine.

Just want to get some insight into possible reasons for this happening, somewhere to start to work out what is causing it and how to fix it.

I just noticed it’s doing the same with the armor too. It’s lower. But it’s also not scaled right either. It’s not taking the scaling from the humanoid scale.

Additionally, sometimes the hat will just be sideways and everything else is fine. I couldn’t get a pic of that glitch yet,

3

What method are you using to attach the hats?

Would you mind sharing some code?

So variable has the info about what gear the hero has. The NPC then runs its script:

local NPC = script.Parent

local NPC_AI = {}

NPC_AI.new = function(NPC)
	
	local this = {}
	--insert bunch of unrelated code here

	local Hero = game.Workspace.HeroInformation

	local Hat =  Hero.Hat.Value

	if Hat == 1 then
		-- Get Crown
		local HatClone = game.ServerStorage.Hats.Crown:Clone()
		HatClone.Parent = NPC
		
	end
	this.Stop = function()
		StateMachine.SwitchState(nil)
	end
	
	return this
end
return NPC_AI

4

Rather than parenting the accessory to the NPC, try using:
Humanoid:AddAccessory(Instance accessory)

2 Likes

So I thought it worked but it’s not happening.

I looked in the NPC at the attachments when they spawned and noticed one of the accessories didn’t have the “BodyBackAttachment”

So I am trying out a wait(0.2) between cloning it and parenting it.
So far so good.