Ad
Still have questions? Join our Discord server and get real time help.
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 1 month ago
Edited 1 month 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