What do you want to achieve?
Stop this occasional glitch.
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.
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,
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