Hi,
It may sound very silly and i might have looked over something but for some reason pathfinding seems to just be completely broken. My script works like it’s supposed to but it just doesnt generate a valid path or something i think?
local PathfindingService = game:GetService("PathfindingService")
local Girl = workspace:WaitForChild("MagazineGirl")
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Path = PathfindingService:CreatePath()
local waypoints
local nextWaypointIndex
local reachedConnection
local blockedConnection
local function CalculatePath(destination)
print('calculating')
local success, err = pcall(function()
Path:ComputeAsync(Girl.PrimaryPart.Position, destination)
end)
if success and Path.Status == Enum.PathStatus.Success then
waypoints = Path:GetWaypoints()
if not reachedConnection then
reachedConnection = Girl.Humanoid.MoveToFinished:Connect(function(reached)
if reached and nextWaypointIndex < #waypoints then
nextWaypointIndex += 1
Girl.Humanoid:MoveTo(waypoints[nextWaypointIndex].Position)
CalculatePath(destination)
else
reachedConnection:Disconnect()
end
end)
end
print('moving to')
nextWaypointIndex = 2
Girl.Humanoid:MoveTo(waypoints[nextWaypointIndex].Position)
else
warn('no path computed', err)
end
end
CalculatePath(Character:WaitForChild("HumanoidRootPart").Position)
Thanks in advance!