Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I improve this script so the AI reacts faster to me changing my position?

Asked by 5 years ago

I made a bot that kinda just... runs towards you. But every five seconds it has to stop to update its pathfinding navigation thingy. Can anyone help me improve this script so that the bot stops less?

while true do
    local path = game:GetService("PathfindingService"):ComputeSmoothPathAsync(script.Parent.Torso.Position, game.Workspace:WaitForChild("DaBrainlessOne").HumanoidRootPart.Position, 100)
    local points = path:GetPointCoordinates()

    script.Parent.Parent.Points:ClearAllChildren()

    for p = 1, #points do
        part = Instance.new("Part")
        part.CanCollide = false
        part.Size = Vector3.new(1,1,1)
        part.Position = points[p]
        part.Anchored = true
        part.Transparency = 0.5
        part.Parent = script.Parent.Parent.Points
        script.Parent.Humanoid:MoveTo(part.Position)
        script.Parent.Humanoid.MoveToFinished:Wait()
    end

    print(path.Status)

end
0
Im pretty sure GetPointCoordinates() as well as the ComputeAsync() methods are deprecated User#24403 69 — 5y
0
They are deprecated. Why are you using multiple deprecated functions? Can I make a guess and say that you found this script in the toolbox and it is not your own? SteamG00B 1633 — 5y
0
I mashed together some scripts from tutorials I found on youtube, some dating back to 2014. DaBrainlessOne 129 — 5y

Answer this question