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

How would I make my AI move once the timer has hit 0?

Asked by 5 years ago

Hello all, I've been trying to make a AI go to a location once a value has gone down to 0, but the AI script doesn't work when i add the value/hunger part, it doesn't work. Any help would be nice!

local torso = script.Parent.HumanoidRootPart.Position
local base = game.Workspace.Finish
local human = script.Parent.Humanoid
local manageHunger = game.StarterGui.ScreenGui.TextLabel
hunger = 100

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

while true do
    hunger = hunger-1
end

manageHunger.Text = hunger

if hunger == 0 then
    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
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

Answer this question