Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

My game is really laggy at certain events?

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

1 comment

0

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

2 answers

✓ Accepted answer

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

0

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

0

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

0

Not a problem happy coding :P

1

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

0

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.