Log in to vote

Pathfinding wants to go up first?

Asked by 1 month ago

Hi I'm new to Pathfinding and I just learned about it in a video by TheDevKing. I followed his tutorial which did worked but I needed to create a few lines of code myself because he is using a character and I'm using a object. I used TweenService instead of MoveTo which would suit my problewm. It works now but there is a slight bug where when it starts it goes up then it comes back down and proceeds with the normal path. I have no idea why this is happening and cant find anything on it. Help. Thanks in advance!

Please keep in mind that it is not enclosed in anything and is a straight shot to the end point with nothing in its path.


local PathfindingService = game:GetService("PathfindingService")
local TweenService = game:GetService("TweenService")

local chase = script.Parent
local human = script.Parent:WaitForChild("Humanoid")

local tweeningInfo =

local path = PathfindingService:CreatePath()
path:ComputeAsync(chase.Position, game.Workspace.End.Position)
local waypoints = path:GetWaypoints()

for i, waypoint in pairs(waypoints) do
    local part ="Part", game.Workspace)
    part.Shape = "Ball"
    part.Material = "Neon"
    part.Size =, 0.6, 0.6)
    part.Position = waypoint.Position +, 2, 0)
    part.Anchored = true
    part.CanCollide = false

    local position = waypoint.Position
    local tweenProperties = {Position = position +,5,0)}
    local tween = TweenService:Create(chase, tweeningInfo, tweenProperties)
Pathfinding Service tries to find the quickest way to get to the waypoint, Since you are using tween service, It has no gravity limitation, So in that case he just fly's all the way up to the endPoint! MattVSNNL 378 — 1mo

Answer this question