Roblox (& Studio) is freezing and lagging with my game. (I don't know what to do)

I am creating a operating system in Roblox but i meet some problems.
I am lagging and freezing (1 fps) when big calculation are made.
And i can’t test all my features cause it throw this error:

Script timeout: exhausted allowed execution time

I cannot find any solution on web.
I want to create a game that is almost like a real operating system.
I am using threads to imitate script to be application.
→ task.spawn
I use FiOne

local Thread = task.spawn(_executable)

I tried to add Actor but this isn’t change the problem.
I tried to optimization with task.wait, not too.
I want fix this cause it’s stop me the progression.

Can you give me a example of a loop optimization?