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

I need this AI to move when a value hits 0, but nothing happens?

Asked by 5 years ago

Hello, I've been trying to make this AI move when a value hits 0, but the entire AI is either really delayed or doesn't work at all. Please help!

local torso = script.Parent.HumanoidRootPart.Position
local base = game.Workspace.Finish
local human = script.Parent.Humanoid
local state = 2

while true do

local path = game:GetService("PathfindingService"):FindPathAsync(torso,base.Position)
local points = path:GetWaypoints()

    for i,v in pairs(points) do
    local p = Instance.new("Part",workspace)
        p.Anchored = true
        p.CanCollide = false
        p.CFrame = CFrame.new(v.Position)
        p.Size = Vector3.new(1,1,1)
    end

    if path.Status == Enum.PathStatus.Success then
        for i,v in pairs(points) do
            human:MoveTo(v.Position)
            human.MoveToFinished:wait()
            if v.Action == Enum.PathWaypointAction.Jump then
                human.Jump = true
            end
        end
    end
end

Answer this question