I have a script in quite a big game which executes an action every second. It works nice in all other games, but not here, as one second legit takes a lwhile. You can see this with tweening too that there is an excessive amuont of lag.
I would like to know how I am able to detect which script is “eating” the resources. Is that possible, and if yes, how?
There is indeed a way to detect the “resource eater”!
It is called the MicroProfiler. Simply press Cntrl F6 or Command F6 to open it up in Studio (you do not need to play the game, but it is also available in game). There, you can see how long a frame lasts, which process is contributing the most in terms of memory, resources, and time.
Here’s the DevHub article about it. There are also tutorial videos within it.
Hope that helps!
Edit 2:
If none of this works, I recommend collecting more data about your problem. Does it get worse over time, or is it constant? If it is the former, I’d suspect a possible memory leak and use the Lua Debugger to “Watch” your variables in a script. If it is the latter, then maybe a function is looping too much or is too intensive to complete in a short amount of time. Really jumping into your code can help you see problems from angles you weren’t looking from before. I hope you find your issue!