Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function pathfind()
- local target = findnearbyplayers()
- if not target then
- local path = pathfinding:CreatePath()
- local rand = humanoidrp.Position + Vector3.new(math.random(-50,50),0,math.random(-50,50))
- path:ComputeAsync(humanoidrp.Position,rand)
- local waypoints = path:GetWaypoints()
- for i,v in pairs(waypoints) do
- if Enum.PathWaypointAction.Jump == v.Action then
- humanoid.Jump = true
- end
- print('no')
- humanoid:MoveTo(v.Position)
- local movefinished = humanoid.MoveToFinished:Wait()
- if not movefinished then
- getunstuck()
- break
- end
- end
- else
- local path = pathfinding:CreatePath()
- path:ComputeAsync(humanoidrp.Position,target.Position)
- local waypoints = path:GetWaypoints()
- for i,v in pairs(waypoints) do
- if Enum.PathWaypointAction.Jump == v.Action then
- humanoid.Jump = true
- end
- humanoid:MoveTo(v.Position)
- local wrap = coroutine.wrap(function()
- if humanoid.WalkToPoint.Y > humanoidrp.Position.Y then
- humanoid.Jump = true
- end
- end)
- wrap()
- local movefinished = humanoid.MoveToFinished:Wait()
- if not movefinished then
- getunstuck()
- break
- end
- if checksight(target) and (torso.Position - target.Position).Magnitude < 20 then
- break
- end
- if i % 5 == 0 then
- if findnearbyplayers() ~= target then
- break
- end
- end
- if (target.Position-waypoints[#waypoints].Position).Magnitude > 8 then
- break
- end
- end
- end
- end
- local function main()
- local target = findnearbyplayers()
- if target then
- if not checksight(target) or (target.Position - torso.Position).Magnitude > 30 then
- pathfind()
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement