when i click when hes mid path he does a zigzag patern until he reaches both positions
heres my code:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ClickEvent = ReplicatedStorage:WaitForChild("ClickEvent")
local pfs = game:GetService("PathfindingService")
local human = script.Parent:WaitForChild("Humanoid")
local torso = script.Parent:WaitForChild("Torso")
ClickEvent.OnServerEvent:Connect(function(player, clickPosition, heldItemName)
print(player.Name .. " clicked at position: " .. tostring(clickPosition) .. " while holding: " .. heldItemName)
if player.Team and player.Team.Name == "Player 1" and heldItemName == "Hero 1" then
local path = pfs:CreatePath()
path:ComputeAsync(torso.Position, clickPosition)
local waypoints = path:getWaypoints()
for i, waypoint in pairs(waypoints) do
human:MoveTo(waypoint.Position)
human.MoveToFinished:Wait(2)
end
end
end)
** You are now Level 2! **