I am struggerling on how to make a vehicle use pathfinding to drive. there is no information on this topic.
this is my current pathfinding code that is used for a npc:
button = script.Parent
local function onbuttonActivated()
print("button")
print("path")
local pathfindingsevice = game:GetService("PathfindingService")
local human = workspace.Dummy:WaitForChild("Humanoid")
local torso = workspace.Dummy:WaitForChild("Torso")
local path = pathfindingsevice:CreatePath({
Costs = {
Water = 20,
Mud = 5,
Neon = math.huge,
Grass = math.huge
}
})
path:ComputeAsync(torso.Position, game.Workspace.EndingPart.Position)
local waypoints = path:GetWaypoints()
for i, waypoint in pairs(waypoints) do
if waypoint.Action == Enum.PathWaypointAction.Jump then
human:ChangeState(Enum.HumanoidStateType.Jumping)
end
human:MoveTo(waypoint.Position)
print(waypoint.Action)
human.MoveToFinished:Wait(2)
end
workspace.Dummy.Humanoid.Health = 0
end
button.Activated:Connect(onbuttonActivated)