Here's the code for reference:
--script for pathfinding enemy to player
local torso = script.Parent.UpperTorso
local position = torso
local lowest = math.huge
local NearestPlayer = nil
for i, v in pairs(game.Players:GetPlayers()) do
if v and v.Character then
local distance = v:DistanceFromCharacter(position)
if distance < lowest then
lowest = distance
NearestPlayer = v
end
end
end
local humanoid = script.Parent
local finishPosition = NearestPlayer
local path = game:GetService("PathfindingService"):ComputeRawPathAsync(torso.Position, finishPosition, 512)
points = path:GetPointCoordinates()
while true do
-- make sure the old points are gone
game.Workspace.Points:ClearAllChildren()
for p = 1, #points do
part = Instance.new("Part")
part.Anchored = true
part.Size = Vector3.new(1,1,1)
part.FormFactor = Enum.FormFactor.Symmetric
part.Parent = game.Workspace.Points
part.Position = points[p]
part.BrickColor = BrickColor.Gray()
end
wait(0.1)
end
How do I make finishPosition be put as the End of the pathfinding?

2 comments
if you guys need more clearance I'd be glad to provide, thank you in advance.
yes, we need all the clearance we can get