Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --SETTINGS
- local showpath = false
- local Destination = workspace.Destination-- YOU CAN CHANGE THIS.
- --SCRIPT CORE
- if Destination==nil then
- error("There is no Destination set for the bot to follow, please check line 3.")
- end
- local destination = Destination.Position
- local pathfindingService = game:GetService("PathfindingService")
- local humanoid = script.Parent.Humanoid
- humanoid.WalkSpeed = 16
- local body = script.Parent:FindFirstChild("HumanoidRootPart") or script.Parent:FindFirstChild("Torso")
- local path = pathfindingService:CreatePath()
- path:ComputeAsync(body.Position, destination)
- local waypoints = path:GetWaypoints()
- repeat wait(1) humanoid:MoveTo(Destination.Position) path:ComputeAsync(body.Position, destination) until path.Status == Enum.PathStatus.Success
- local waypoints = path:GetWaypoints()
- for i = 1,#waypoints do
- if showpath == true then
- local part = Instance.new("Part",workspace)
- part.Name = i
- part.Anchored = true
- part.Position = waypoints[i].Position
- part.CanCollide = false
- part.Size = Vector3.new(1.5,1.5,1.5)
- part.Transparency = 1
- if i ~=1 then
- other = workspace:FindFirstChild(tostring(i-1))
- if other~=nil then
- local mag = (other.Position-part.Position).Magnitude
- local trail = Instance.new("Part",workspace)
- trail.Name = "trail"..i
- trail.Size = Vector3.new(0.5,0.5,mag)
- trail.CFrame = CFrame.new(other.Position,part.Position)*CFrame.new(0,0,-mag/2)
- trail.Anchored = true
- trail.CanCollide = false
- end
- end
- end
- end
- for k, waypoint in pairs(waypoints) do
- if path.Status == Enum.PathStatus.Success then
- humanoid.WalkToPoint = waypoint.Position
- if waypoint.Action == Enum.PathWaypointAction.Jump then
- humanoid.WalkSpeed = 0
- wait(0.3)
- humanoid.WalkSpeed = 16
- humanoid.Jump = true
- end
- humanoid.MoveToFinished:Wait(2)
- else
- repeat path:ComputeAsync(body.Position,destination) until path.Status == Enum.PathStatus.Success
- end
- end
Advertisement
Advertisement