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

How would I change this script so if it has no target it goes to a certain part?

Asked by 4 years ago
Edited 4 years ago

I know nothing about stuff like this, so help would be appreciated :)

I am making a zombie that goes to a certain part when it has no target

Part of the script:

function walkRandomly()
    local xRand = math.random(-50,50)
    local zRand = math.random(-50,50)
    local goal = myRoot.Position + Vector3.new(xRand,0,zRand)

    local path = game:GetService("PathfindingService"):CreatePath()
    path:ComputeAsync(myRoot.Position, goal)
    local waypoints = path:GetWaypoints()

    if path.Status == Enum.PathStatus.Success then
        for _, waypoint in ipairs(waypoints) do
            if waypoint.Action == Enum.PathWaypointAction.Jump then
                myHuman.Jump = true
            end

Answer this question