NPC falling over randomly

So I have this script here using the pathfinding service to navigate a NPC to the spawn from a till.

local character = script.Parent
			local humanoid = character.Humanoid
			
			character.HumanoidRootPart.Anchored = false
			
			local destination = game.Workspace.NPCSpawner.SpawnPart.Position
			
			local path = PathFindingService:CreatePath()
			path:ComputeAsync(character.HumanoidRootPart.Position, destination)
			
			local waypoints = path:GetWaypoints()
			for i,v in pairs(waypoints) do
				humanoid:MoveTo(v.Position)
				humanoid.MoveToFinished:Wait()
			end
			character:Destroy()

(Not all of it is included as it’s a long script and this is the nessecary part)
However, when the NPC leaves the till it somtimes falls over. There are no blocks there that it can fall over on, there is only one block telling where to go to and cancollide is turned off for that block. Does anyone know how to fix this?

1 Like

I’m not sure what your world scene looks like, but you should be able to fix it by adding a BodyGyro instance to the HumanoidRootPart making sure the MaxForce property’s Y value is set to 0. In addition to that, make sure that the Humanoid’s AutoRotate property is enabled so that it faces the direction it’s going.

4 Likes

Seems to work perfectly fine, Thank you

1 Like