First for some context/variable explanations. HRPart is the humanoidrootpart of the NPC, and CauldronMain is a part in the workspace. The code is running in the model of the NPC. The excerpt posted below is wrapped in a while true do loop.
This is the code.
local Path = PathfindingService:FindPathAsync(HRPart.Position, CauldronMain.Position)
if Path.Status == Enum.PathStatus.Success then
local Waypoints = Path:GetWaypoints()
for i, Waypoint in pairs(Waypoints) do
Humanoid:MoveTo(Waypoint.Position)
local Connection
if Waypoint.Action == Enum.PathWaypointAction.Jump then
Humanoid.Jump = true
Connection = Humanoid.Changed:connect(function()
Humanoid.Jump = true
end)
end
local Reached = Humanoid.MoveToFinished:Wait()
if Connection then
Connection:Disconnect()
end
if not Reached then
break
end
end
end
When running it in play solo the monsters move normally, but when I play the actual game they stutter. In between every waypoint, for around 0.4 seconds their animation stops, and then resets. This looks really awful in-game and is very immersion-breaking, which is why I want to fix it.
If anyone wants to I can post the link to the game.