Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Scripts perform slower than written?

Asked by 6 years ago
Edited 6 years ago

While likely the cause of lag, with a big game, the scripts in the game execute very slowly. Even a "wait()" will take about a half-second. It's a very unreliable script system if you script by timing. I realize this may be unsolvable, and it's just the size of the game causing the scripts to slow, but if there's a solution for the scripts to run at a more normal speed, I'd love to hear it. Other than the scripts, the game runs just fine at a nice 60fps on my computer. Really, the only thing slow are the scripts, which is odd to me.

1 answer

Log in to vote
0
Answered by
Vexture 179
6 years ago

If you're running on a local script and want something to happen as fast as your game's framerate can render, use

game:GetService("RunService").RenderStepped:connect(function() --RenderStepped fires every time a frame is rendered.
    --do stuff!
end)

Hope this helps!

0
That sounds like a really cool trick, actually, thank you! Is it possible to do something similar for non-local scripts? SuperJumpman12 43 — 6y
0
Unfortunately not. :( Vexture 179 — 6y
0
A general rule of thumb is to optimize your code. Don't make the server do anything unless it absolutely has to! (i.e. making sure every other person can see a change in the game world). Vexture 179 — 6y
0
Alright, thanks for the help! SuperJumpman12 43 — 6y
Ad

Answer this question