Problem:
The NPC do not compleate the path and don’t even follow the path. The calculations are super good. and works, but I dont know why the NPC dont follow the path.
script:
local PathfindingService = game:GetService("PathfindingService")
wait(math.random(1,5))
--Just for a small wait
local human = script.Parent:WaitForChild("Humanoid")
local torso = script.Parent:WaitForChild("Torso")
local NPCLocations = game.Workspace.NPCLocations:GetChildren()
local Endpart = NPCLocations[math.random(1, #NPCLocations)]
--This will take it to a random RED brick, you can see 1 in the video, I have only 1 for now.
--Path Costs
local path = PathfindingService:CreatePath({
AgentRadius = 3,
AgentHeight = 6,
AgentCanJump = true,
AgentCanClimb = true,
Costs = {
Grassfield = 10
}
})
path:ComputeAsync(torso.Position, Endpart.Position)
local waypoints = path:GetWaypoints()
for i, waypoint in pairs(waypoints) do
local part = Instance.new("Part")
part.Shape = "Ball"
part.Material = "Neon"
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
end
human:MoveTo(Endpart.Position)
video:
robloxapp-20221111-1340375.wmv (1.2 MB)