This works completely fine without issues in studio. However, when I play the game on Roblox I get “Script timeout: exhausted allowed execution time” and it usually points to a random line in the code which is odd.
What solutions have you tried so far?
I’ve already looked around the code and tried different things. The only solution is to remove the shown line of code. It’s worth mentioning I’ve tried putting this line in a coroutine to see if that would help the issue and the problem still persists
Terrain:CopyRegion causing script timeouts is likely due to the heavy computational load required to copy a large region of terrain. This can easily exceed the execution time limit for a single script especially when running outside of studio.
You have a couple options here:
Instead of copying the entire region in one go, break it down into smaller parts.
Use Task Scheduling: You can also use the task.defer or task.wait to yield the execution and avoid hitting the timeout limit.
Thank you for posting your solution, I decided to go with copying the terrain as an object in studio and parenting it to server storage and just pasting it to the terrain during runtime. I still had to divide the terrain in 2 but this takes out the extra lines of code that otherwise would of caused further issues. Thank you again!
Here’s the link to the forum post where I found this solution