Pet not jumping (path finding service issue)

So, I am wanting to have a pet that follow’s me using path finding service. It follow’s me smoothly but the issue is that it can’t jump on simple block obstacles.

Vid:

Script:

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local Pathfinding = game:GetService("PathfindingService")
local Dummy = workspace.FlightFireCommon.BabyDragon
local humanoid = Dummy.Humanoid

function Run_()
	local Path = Pathfinding:CreatePath({
		AgentCanJump = true;
		Costs = {};
	})

	local success, err = pcall(function()
		Path:ComputeAsync(workspace.FlightFireCommon.BabyDragon.PrimaryPart.Position,player.Character.PrimaryPart.Position)
	end)

	local waypoints = Path:GetWaypoints()
	
	Path.Blocked:Connect(function()
		Run_()
		Dummy.Humanoid.Jump = true
	end)

	for i, waypoint in pairs(waypoints) do
		if Dummy:FindFirstChild("BreakPath").Value == true then return end

		if waypoint.Action == Enum.PathWaypointAction.Walk then
			local Anim = Dummy.Humanoid:LoadAnimation(Dummy.MovingAnim)
			Anim:Play()
			Dummy.Humanoid:MoveTo(waypoint.Position)
			Dummy.Humanoid.MoveToFinished:Wait()
			Anim:Stop()
		elseif waypoint.Action == Enum.PathWaypointAction.Jump then
			Dummy.Humanoid.Jump = true
		end
	end

	if not success then
		warn(err)
	end
end

repeat wait(1) until game:IsLoaded()

local BreakPath = Dummy.BreakPath

BreakPath.Changed:Connect(function()
	BreakPath.Value = false
end)

game:GetService"RunService".Heartbeat:Connect(function()
	Run_()
	BreakPath.Value = true
end)
1 Like

Is path finding what you want? You could’ve achieved it being to the side instead by using AllignPosition mixed with body gyro for turning + setting a can collide to false for the pet so it’ll just stick to an offset whilst trailing the player

You see here if I use those, I won’t be able to play an Animation that I want for the dragon. I also want it to have obstacle detection so that it doesn’t ram into things.

Btw my dragon sometimes doesn’t even follow the player… if someone can help me make my dragon follow the player with path finding service that’d be nice.

This post has a similar problem to yours, try their solution out: