Pause for random amount of time at waypoint

Hey guys, I have a script it works as is, but I can’t seem to add a random pause at each waypoint. Basically right now he walks to each way point and moves on, I am trying to make him pause at each waypoint, Such as sometimes he will be standing there for 5 seconds, other times he might be standing there for 30 seconds before moving on. Any ideas? A timer of sorts? Also if you are a c# genius, I am trying to make him walk to a random waypoint instead of a set path. : 3

void Patrolling ()
	{
		// Set an appropriate speed for the NavMeshAgent.
		nav.speed = patrolSpeed;
		
		// If near the next waypoint or there is no destination...
		if(nav.destination == lastPlayerSighting.resetPosition || nav.remainingDistance < nav.stoppingDistance)
		{
			// ... increment the timer.
			patrolTimer += Time.deltaTime;
			
			// If the timer exceeds the wait time...
			if(patrolTimer >= patrolWaitTime)
			{
				// ... increment the wayPointIndex.
				if(wayPointIndex == patrolWayPoints.Length - 1)
					wayPointIndex = 0;
				else
					wayPointIndex++;
				
				// Reset the timer.
				patrolTimer = 0;
			}
		}
		else
			// If not near a destination, reset the timer.
			patrolTimer = 0;
		
		// Set the destination to the patrolWayPoint.
		nav.destination = patrolWayPoints[wayPointIndex].position;

	}

There really are a million different ways to do it.

Look into the Random.Range documentation to see how to implement a number generator. See the link below.

To pause you could use something like
Random.Range(0, 10) and have the object wait through that range.

As far as the Waypoints go, try and play around with creating your own algorithm or look up anothers.

You could just have it visit adjacent nodes base on whether the random range returns a negative or positive and alternate between going up and down or side to side. It is really up to you.

Or you could do a range from 0-5 and have it go towards the index it needs to go. Does that make sense? In my example below O is the location of the object, and G is the goal of where you want to go. 0-5 would represent the spaces (1) that it can travel.

[1,O,1]

[1,1,1]

[1,G,1]