Not a coding question but a practice question, what is the best way to write loops ( been using i,v in pairs) and is using module scripts laggy. Also what is the best way to eliminate lag from unknown problems(finding them and fixing them), Thank you
My game is really laggy at certain events?
2 answers
In roblox studio under view there is a script performance window which will help you find which script are lagging.
Also I haven't tested this but splitting all of the scripts apart may help to spread the workload so that all of the work is not being done by one or two scripts.
hope this helps
4 comments
IF I use this and slove the problem I will accept the answer. I believe my game is optimize and I have one leak in the code
It is my playerlist it seems to be calling stuff lots of times when not needed, So I delayed it and removed update theards and it seems to work perfectly and lag has stoped. Thanks :D ACCEPTED ANSWER
Not a problem happy coding :P
Splitting up scripts will not "spread the workload". In the end, the same work will have to be done (technically a bit more because each script adds at least one coroutine, but I imagine that's negligible).
For loops, I suggest you read this
Another thing to take note is the Spawn function and coroutines. Using separate threads instead of just one may improve the performance in your scripts.
1 comment
Using additional coroutines won't improve the performance of your script. Coroutines do not run in parallel.
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Using module scripts should be no more laggy than using regular scripts to do the same thing.