Exit the repeat Loop after some time limit

I am Using the Repeat loop and i want to Come out of the loop after certain time (Ex:-2 minutes).

Thanks in advance

-- setup some fun for use later in this script.
set (something, wonderful) to \
  ( "put the long time" & return, "wait 1 second" )

-- '120 seconds', '120000 milliseconds' also work
set delay to 2 minutes

set startTime to the time
repeat until the time >= startTime + delay
 try to do something && wonderful  -- Its valid syntax!
end repeat

Here’s another variation on the same theme:

set endTime to the time + 10 seconds
repeat while the time is earlier than endTime
	put the long time
	wait a second
end repeat

Just replace “10 seconds” with your required delay time, and the body of the repeat loop with your own code.