Help to optimize a script

Hello. I am trying to make a stand game but the problem is that one ability takes 11 seconds to load (Ability Function Has: 800+ lines of code). I tried to optimize (From DevForum) but it does not make a big difference. The script has very much corontine.wrap(), if statements, else, loops but i cant remove them.
You might ask why u need if statements?
I need to make fully customable like [“Damage”] = 10, etc…

How do i optimize my script?

2 Likes

send the script first so i can see how to optimize it

2 Likes

there is not much context on what’s going on with your script, but

you might want to rewrite it all from scratch (if its really that bad)

2 Likes

I will try to change some things

1 Like

The biggest time waste will be any yielding like calling wait(). Another big time waster is loops. Line count usually doesn’t affect it and excepting very rare cases, using if statements won’t really affect the speed of the code too.

Since the game isn’t completely stalling (or at least you didn’t say that). I’m assuming your using wait or task.wait() for timing things or stuff. The most likely thing to speed up your code would be to remove as much of those as you can, or making it so that any yields get spawned as their own task so it doesn’t effect the main part.

2 Likes

Thank you. I checked waits and i saw some waits that isn’t in a coroutine.wrap(function() end)().
No more delay :smiley:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.