# Error: Scrip has exceeded its maximum running time

**URL:** <https://forums.unrealengine.com/t/error-scrip-has-exceeded-its-maximum-running-time/864262>\
**Category:** Verse\
**Tags:** unreal-editor-for-fortnite, fortnite-creative, question, fortnite\
**Created:** [April 6, 2023, 6:29pm UTC](https://forums.unrealengine.com/t/error-scrip-has-exceeded-its-maximum-running-time/864262 "2023-04-06T18:29:05Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![FinestCreative](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/finestcreative/32/1034971_2.png) [@FinestCreative](https://forums.unrealengine.com/u/FinestCreative)\
**Post date:** [April 6, 2023, 6:29pm UTC](https://forums.unrealengine.com/t/error-scrip-has-exceeded-its-maximum-running-time/864262/1 "2023-04-06T18:29:05Z")

</div>

I made an AI for my chess game using the MinMax algorithm to generate a decision tree. If I set the depth value for the tree generation to 1, it works, because the tree only has like up to 50 nodes. But if I go any deeper and it has to do 1-1000 nodes, all the verse code in the map stops working it seems and I get this error:  
`Error: Scrip has exceeded its maximum running time`

In short, is there a fix that will allow me do to more intense computations?

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/f/7/7f775725cb5228b5ead8c0c4a08b9e9a2f0f849f.jpeg "verse error") ](https://www.youtube.com/watch?v=AXyd2eC_f0g)

The function if you are interested:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/3/c/43cb5aabf858641ca47fcad35fe14eff49bfdcf8.png)  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/d/4/1d494b0b1c2f04e1812e1bfe5f889641adfdae4c.png)

---

<div class="post-metadata">

**Author:** ![Incredulous\_Hulk](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/incredulous_hulk/32/924210_2.png) [@Incredulous\_Hulk](https://forums.unrealengine.com/u/Incredulous_Hulk)\
**Post date:** [April 6, 2023, 7:35pm UTC](https://forums.unrealengine.com/t/error-scrip-has-exceeded-its-maximum-running-time/864262/2 "2023-04-06T19:35:05Z")

</div>

Looking at the code one option you have is to manually time-slice your script. Since this is a suspends function you could try sleeping inside the `for` loop after N iterations.

For example:

```auto
for (I->Piece : Board.Pieces):
    # do some computation
    
    # If index I perfectly divides by 100 sleep for a frame
    if (Mod[I, 100] = 0):
        Sleep(0.0)

```

---

<div class="post-metadata">

**Author:** ![FinestCreative](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/finestcreative/32/1034971_2.png) [@FinestCreative](https://forums.unrealengine.com/u/FinestCreative)\
**Post date:** [April 6, 2023, 7:49pm UTC](https://forums.unrealengine.com/t/error-scrip-has-exceeded-its-maximum-running-time/864262/3 "2023-04-06T19:49:44Z")

</div>

> [@Incredulous\_Hulk](#):
>
> t the code one option you have is to manually time-slice your script. Since this is a suspends function you could try sleeping inside the `for` loop after N iterations.

WHAT A COINCIDENCE, I just tried the same thing and it works. Do you know why this works becaues I dont really understand how this fixes it?

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/f/7/cf72be6c7ffaaed28d143390841d9bdecfaaaad1.png)

---

<div class="post-metadata">

**Author:** ![Incredulous\_Hulk](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/incredulous_hulk/32/924210_2.png) [@Incredulous\_Hulk](https://forums.unrealengine.com/u/Incredulous_Hulk)\
**Post date:** [April 6, 2023, 8:20pm UTC](https://forums.unrealengine.com/t/error-scrip-has-exceeded-its-maximum-running-time/864262/4 "2023-04-06T20:20:16Z")

</div>

Verse has internal checks that try to prevent scenarios where you can do things like infinite loops, super long processing, etc. This is how we ensure that a bad script cannot completely ruin the user experience or lock up the server. By adding a sleep to this code you are yielding back execution for other Verse code to run. This also has the effect of resetting those internal “too long to process” counters for your code.

---

<div class="post-metadata">

**Author:** ![FinestCreative](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/finestcreative/32/1034971_2.png) [@FinestCreative](https://forums.unrealengine.com/u/FinestCreative)\
**Post date:** [April 26, 2023, 1:11pm UTC](https://forums.unrealengine.com/t/error-scrip-has-exceeded-its-maximum-running-time/864262/5 "2023-04-26T13:11:32Z")

</div>

I get the same excesive computation error on this single line of code. Any idea how you would timeslice this?

```auto
TaggedBlocksL:[]creative_object_interface := GetCreativeObjectsWithTag(grassblocktag{})

```

In my map I have 15,000 props, 10,000 of them are tagged with the tag grassblocktag

---

<div class="post-metadata">

**Author:** ![apersonbeing](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/apersonbeing/32/639449_2.png) [@apersonbeing](https://forums.unrealengine.com/u/apersonbeing)\
**Post date:** [April 26, 2023, 8:40pm UTC](https://forums.unrealengine.com/t/error-scrip-has-exceeded-its-maximum-running-time/864262/6 "2023-04-26T20:40:09Z")

</div>

I ran into this too, but I only had about 450 props and prop movers tagged. I reduced it down below 400 for each and it worked ok after that. I assumed it had something to do with too many prop movers and just moved on. I’d be curious if you found a solution to this.

---

<div class="post-metadata">

**Author:** ![MattRix](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mattrix/32/686548_2.png) [@MattRix](https://forums.unrealengine.com/u/MattRix)\
**Post date:** [April 27, 2023, 3:23am UTC](https://forums.unrealengine.com/t/error-scrip-has-exceeded-its-maximum-running-time/864262/7 "2023-04-27T03:23:13Z")

</div>

My guess is you’ll probably need to split your props into a bunch more different tags instead of having them all use one tag, (and maybe Sleep(0.0) between each call to GetCreativeObjectsWithTag)

---

<div class="post-metadata">

**Author:** ![Incredulous\_Hulk](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/incredulous_hulk/32/924210_2.png) [@Incredulous\_Hulk](https://forums.unrealengine.com/u/Incredulous_Hulk)\
**Post date:** [May 3, 2023, 11:06pm UTC](https://forums.unrealengine.com/t/error-scrip-has-exceeded-its-maximum-running-time/864262/8 "2023-05-03T23:06:14Z")

</div>

@FinestCreative

In this circumstance there isn’t much you could do as it is the underlying Verse function you’re calling that is timing out. As a few other users have pointed out, you could go and re-tag content so that you have fewer matches. Then you could request groups of things one tag at a time.

I also reported the timeout problem internally to get more eyes on it. I can’t report on any long term solutions or future language changes. However, in the short term we’re going to be extending the timeout duration for Verse scripts. This should greatly reduce the amount of times people hit this brick wall. That change should be rolled out very soon, assuming it hasn’t already been released.

---

<div class="post-metadata">

**Author:** ![FinestCreative](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/finestcreative/32/1034971_2.png) [@FinestCreative](https://forums.unrealengine.com/u/FinestCreative)\
**Post date:** [May 4, 2023, 8:38am UTC](https://forums.unrealengine.com/t/error-scrip-has-exceeded-its-maximum-running-time/864262/9 "2023-05-04T08:38:11Z")

</div>

> [@Incredulous\_Hulk](#):
>
> y to get more eyes on it. I can’t report on any long term solutions or future language changes. However, in the short term we’re going to be greatly extending the timeout duration for Verse scripts. This should greatly reduce the amount of times people hit this brick wall. That change should be rol

That is amazing, I do have to timeslice my code quite often, for example with chess, or looping over 15k actors.
