You can see everything on the video, I have no idea of how to properly describe this.
My code is:
-- MODULE SCRIPT
function NPCModule.Move(Location, Character)
print("move")
local pathParts = Instance.new("Model")
pathParts.Parent = workspace
local PathFindingService = game:GetService("PathfindingService")
local path1 = PathFindingService:CreatePath()
path1:ComputeAsync(Character:WaitForChild("HumanoidRootPart").Position, Location)
local waypoints1 = path1:GetWaypoints()
for _, waypoint in pairs(waypoints1) do
local part = Instance.new("Part")
part.Shape = "Ball"
part.Material = "Neon"
part.Size = Vector3.new(1,1,1)
part.Position = waypoint.Position
part.Anchored = true
part.CanCollide = false
part.Parent = pathParts
end
for _, waypoint in pairs(waypoints1) do
Character.Humanoid:MoveTo(waypoint.Position)
end
end
--LOCAL SCRIPT
tool.Activated:Connect(function()
if equipped then
local p = mouse.Hit.p
local ray = workspace:Raycast(p,Vector3.new(0, -1000, 0))
local FormationM = workspace.Formation
local FormationPrimary = FormationM.PrimaryPart
local Finish1 = FormationM.Place1
local Finish2 = FormationM.Place2
local InformationTable =
{
Finish1 = FormationM.Place1.Position;
Finish2 = FormationM.Place2.Position;
Direction1 = Finish1.Direction1.Position;
Direction2 = Finish2.Direction2.Position;
}
if not ray then
FormationM:MoveTo(p, FormationPrimary)
event:FireServer(Player.Name, InformationTable)
else
FormationM:MoveTo(ray.Position, FormationPrimary)
event:FireServer(Player.Name, InformationTable)
end
end
end)