[FREE] Always following script which makes bot jump also

Paste this code under your bot in a script.

local PathfindingService = game:GetService("PathfindingService")
local Path = PathfindingService:CreatePath({
    AgentRadius = 3,
    AgentHeight = 6,
    AgentCanJump = true,
    Costs = {
        Water = 20
    }
})
while task.wait(1) do
    for i,Player in pairs(game:GetService("Players"):GetPlayers()) do
        Path:ComputeAsync(script.Parent.UpperTorso.Position,Player.Character:FindFirstChild("HumanoidRootPart").Position)
        local Waypoints = Path:GetWaypoints()
        for i,waypoint in pairs(Waypoints) do
            if waypoint.Action == Enum.HumanoidStateType.Jumping then
                script.Parent.Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
            end
            script.Parent.Humanoid:MoveTo(waypoint.Position)
            script.Parent.Humanoid.MoveToFinished:Wait()
        end
        script.Parent.Humanoid:MoveTo(Player.Character:FindFirstChild("HumanoidRootPart").Position)
    end
end

Just want to help the ones who don’t understand PFS properly. Modify the above code as your desire and if there are any errors regarding Character being nil, put this line just after the for loop.

local Character = Player.CharacterAdded:Wait() or Player.Character

This will make the script wait until your avatar is fully loaded.
Goodluck!

Here is the output with raw code:


4 Likes

I think this is more performant (I didn’t test it)

local PathfindingService = game:GetService("PathfindingService")
local Path = PathfindingService:CreatePath({
    AgentRadius = 3,
    AgentHeight = 6,
    AgentCanJump = true,
    Costs = {
        Water = 20
    }
})

while true do
    for _, Player in pairs(game:GetService("Players"):GetPlayers()) do
        local playerRoot = Player.Character:FindFirstChild("HumanoidRootPart")
        if playerRoot then
            Path:ComputeAsync(script.Parent.UpperTorso.Position, playerRoot.Position)
            local Waypoints = Path:GetWaypoints()
            
            for _, waypoint in pairs(Waypoints) do
                if waypoint.Action == Enum.HumanoidStateType.Jumping then
                    script.Parent.Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
                end
                script.Parent.Humanoid:MoveTo(waypoint.Position)
            end
            
            script.Parent.Humanoid.MoveToFinished:Wait()
        end
    end
    task.wait(1)
end

this will throw an error if player hasnt loaded because HumanoidRootPart will be nil.
Remove the declaration of playerRoot variable and then put the assigned data as a condition for if statement.

1 Like