I want to make a pathfinding script to a car, but the car should only be able to drive on the roads. Therefore I want to create a wall that the players can walk through, but not an NPC car.
I made a simple pathfinding script, but I don't know how to make it so it can't go off the road.
while true do
path = game:GetService("PathfindingService"):ComputeRawPathAsync(workspace.Start.Position, workspace.Finish.Position, 400);
points = path:GetPointCoordinates()
game.Workspace.Points:ClearAllChildren()
for p = 1, #points do
part = Instance.new("Part");
part.FormFactor = Enum.FormFactor.Symmetric
part.CanCollide = false
part.Size = Vector3.new(1,1,1)
part.Position = points[p]
part.Anchored = true
part.BrickColor = BrickColor.Gray()
part.Parent = game.Workspace.Points
end
wait(0.5)
end
Please help. Thanks!

1 comment
You could place the wall in everyone's Camera and manipulate it accordingly to each client.