NPC sometimes spawns stuck in the ground and walks incorrectly

I’m facing an issue with my NPC system. When spawning an NPC, there’s a chance that it spawns partially inside the ground. As a result, the NPC gets “stuck” and starts walking in an incorrect animation state, as if it’s sunk into the ground

I’ve already tried spawning the NPC a few studs above the ground (e.g., 3 studs higher), Delaying AI + Animate for ~1.5s after cloning., but the issue still happens randomly.

for i=setings.KillersPerWave,1,-1 do

					local killer:Model = randomKiller:Clone()
					killer.Parent = workspace.KillersHolder
					killer:PivotTo(spawnPart.CFrame * CFrame.new(0,3,0) * CFrame.new(math.random(-10,10),0,math.random(-10,10)))
					

					
					local aiScript = script.Ai:Clone()
					aiScript.Parent = killer
					
					local animateScript = script.Animate:Clone()
					animateScript.Parent = killer
					
					task.delay(1.5,function()
						aiScript.Enabled = true
						animateScript.Enabled = true
					end)
					task.wait(setings.KillerSpawnKD)
				end

Maybe try to increase the Y axis ?

Try switching these 2 lines. You’re putting it into the workspace first, then moving it.
Move it’s location, then put it in the workspace.

1 Like

By the looks of it, is your killer a custom player model? If so, have you tried adjusting the hip height?

The HipHeight is probably ok since it’s only happening once in a while. If it got stuck every time I’d suspect it was the issue.

yeah its the only way to make the corrupted bot walk properly by adjusting a hip height. But how i could detect which of the bots is bugged

Like I said above, I don’t think it’s a HipHeight issue if they walk normally most of the time.