Hello, I started to learn Pathfinding service recently, and I’m trying to make an NPC jump when supposed to. I watched DevKings pathfinding service video on how to make the character jump when needed, but sometimes it just double jumps mid-air.
https://www.youtube.com/watch?v=VWKNtqjPKn0
Heres script:
local PathfindingService = game:GetService(“PathfindingService”)
wait(2)
local human = script.Parent:WaitForChild(“Humanoid”)
local torso = script.Parent:WaitForChild(“Torso”)
local path = PathfindingService:CreatePath()
path:ComputeAsync(torso.Position, game.Workspace.endingPart.Position)
local waypoints = path:GetWaypoints()
for i, waypoint in pairs(waypoints) do
local part = Instance.new("Part")
part.Shape = "Ball"
part.Material = "Neon"
part.Size = Vector3.new(0.6, 0.6, 0.6)
part.Position = waypoint.Position + Vector3.new(0,2,0)
part.Anchored = true
part.CanCollide = false
part.Parent = game.Workspace
if waypoint.Action == Enum.PathWaypointAction.Jump then
human:ChangeState(Enum.HumanoidStateType.Jumping)
end
human:MoveTo(waypoint.Position)
human.MoveToFinished:Wait(2)
end
human:MoveTo(game.Workspace.endingPart.Position)
Place:
PathfindingService(DevForum).rbxl (23.7 KB)