So, I've got a problem with that script. It basically moves the player to the destination, but the waypoints are not showing as parts and for some reason it does not jump when it should.
local PathfindingService = game:GetService("PathfindingService")
local Player = game.Workspace.kapipi12
local Humanoid = Player.Humanoid
local destination = game.Workspace.endingPart
local path = PathfindingService:CreatePath()
local waypoints
local currentWaypointIndex
for i, waypoint in pairs(path:GetWaypoints()) do
local Part = Instance.new("Part")
Part.Shape = "Ball"
Part.Material = "Neon"
Part.BrickColor = BrickColor.new("Royal purple")
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
Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
end
Humanoid:MoveTo(waypoint.Position)
Humanoid.MoveToFinished:Wait(2)
end
local function followPath(destinationObject)
path:ComputeAsync(Player.HumanoidRootPart.Position, destinationObject.Position)
waypoints = {}
if path.Status == Enum.PathStatus.Success then
waypoints = path:GetWaypoints()
currentWaypointIndex = 1
Humanoid:MoveTo(waypoints[currentWaypointIndex].Position)
else
Humanoid:MoveTo(Player.HumanoidRootPart.Position)
end
end
local function onWaypointReached(reached)
if reached and currentWaypointIndex < #waypoints then
currentWaypointIndex = currentWaypointIndex + 1
Humanoid:MoveTo(waypoints[currentWaypointIndex].Position)
end
end
local function onPathBlocked(blockedWaypointIndex)
if blockedWaypointIndex > currentWaypointIndex then
followPath(destination)
end
end
path.Blocked:Connect(onPathBlocked)
Humanoid.MoveToFinished:Connect(onWaypointReached)
followPath(destination)
