This script seems to be slowing my game down a lot

This seems to be worse then before.

If that’s the case then your lag is purely originating from your PC, which means that you cannot fix it.

Either that or you have to change WAIT_TIME to something larger than 0.25. That’s what you’ll have to settle for if you want a simple disco floor.

324 unanchored parts, changing colors every 1/30 second → 60 fps
There’s something wrong with your computer.

I think you mean his computer.

Can I give you the game link then you see if it is lagging from your computer.

Freestyle! - Roblox As soon as I join in the actual app it feels like it will crash your computer.

Yes I meant him but I forgot.

@henberrysodapop
I’ve played this game yesterday, you must know that your game has thousands of parts and there’s no way a simple script which changes a color every quarter of a second will break your game.

I played on mobile and it was running smooth. Just when I showed someone it they said that is was freezing up for them and their PC usually runs smoothly.

It freezes on my Windows device.
There may be a memory leak.

What is a memory leak? I have heard it before just never actually looked up what it is.

If there’s lag in your game then the code you posted definitely isn’t causing it.

Whenever I remove the code my game runs smoothly again, I think it is that.

The while loop is not running fast enough to slow down the game. And you said the inner loop is only running around 20 iterations. There has to be something else. Is what you showed the entire script?

This is being annoying because my game has so so many parts and lags by this script, with no memory leaks form the looks of it.

Yes, that is the whole color changing part which is making the game freeze.

I tried changing one parts color every five seconds and it still lags, I do not think this is my fault anymore.

I don’t think your disco floor is the problem behind the lag. You may have other scripts running in the background causing it.

Instead of putting the Colors in the functions why not just put it where you put the color variables.

It is, when I disable the script my game is smooth.