Lagging on changing brick color, as well as transparency change

I’m experiencing a lag issue that I’ve been trying to resolve. I put my project away for a while to focus on other things, and came back to some painful lag when:

  1. Changing brick color
  2. Changing brick transparency

In order to diagnose the cause of the lag I’ve disabled all scripts and have gone through each of them.

With all other scripts disabled, this is causing lag (and also occurs if I change the brick color of a single brick as well):

local teleporter  = script.Parent

while true do
	teleporter.Transparency = 0
	wait(3)
	teleporter.Transparency = 1
	wait(3)
end

Not that this is not a device issue.
Reproduced on:

  1. Mobile
  2. A system running an i7 (8th gen), 16GB mem
  3. A system running an i7 (10th gen), 32GB mem, dedicated graphics card
    While # 3 was is least painful, the lag is still noticeable

Has anybody experienced this, or have any ideas on how to resolve such an issue?

2 Likes

You may have a data leak inside your game, I do not know how to fix that but changing brickcolors certainly should not cause lag, unless you are changing it without very much delay. The brickcolor could be connected to lots of events which can cause lag. Although I believe it is a memory leak.

1 Like

Either you missed a script or this script is in 1000s of objects, because that code will not cause any lag. Are you sure there is no other code running? It’s also not lagging in 3 second intervals.

Single script inside single block.
Looped through and disabled all other scripts within the context of the place and performed many tests, including disabling and enabling the sample (which causes the lag in the vid)

image

Like in my other message most likely a data leak.

That code will not cause lag on its own. Is the teleporter part getting cloned many times? Are you disabling the scripts after the game is run or before the game is run?

If other scripts were enabled I could possibly agree that it could be a memory leak of sorts. As you can see in the script block posted, there is a long enough wait.

I cannot seem to find the problem then, I recommend you go to #bug-reports for this problem.

All other scripts were disabled before publishing and testing in order to narrow down where the problem exists. The teleporter block in this instance is static; nothing is getting cloned. Currently, the script containing the code block posted is enabled.

Before I stopped working on the project for a while these issues did not exist, so it’s somewhat confusing. I had a handful of models running color change scripts previously without issue.

Instead of having:

while true do
script.Parent.Transparency = 0
wait(3)
script.Parent.Transparency = 1
wait(3)
end

You could put a wait() before the while true do.
For example:

while true do
wait()
script.Parent.Transparency = 0
wait(3)
script.Parent.Transparency = 1
wait(3)
end

This usually helps fix with lag whenever I’m using a while true do.

can definitely try that out, though the wait(3) at the end of the loop (in any language) should be sufficient.

Is there still lag if you transfer the code to a LocalScript? I always try to keep anything visual, like particle effects, on the client only.

Yes, same result moving it local

Did you find a solution yet or not

1 Like

No, never did. I ended up changing/removing the bits that were causing issues.

1 Like

im not sure if it would do much but try doing while wait() do instead of while true do

No, had the same result. Same with task.wait.