Better way to register where to place pixels when mouse down

Just want to step in a second here and throw down my thread, as I feel it’s relevant here.

This code is a perfect example of how to blatantly abuse conditions for while loops, specifically under yielding at the start of every iteration and thus producing finnicky results. What you should be doing is spawning the loop right when a draw action needs to be performed and terminating it when it no longer has use.

while hold do
    if ColorPicker.Visible then
        Draw:FireServer(mouse.X, mouse.Y) -- Bad for performance
    end
    wait() -- 1/30th second + additional time to search for free TS slot
end

You aren’t using a while loop anymore (which is good) so this is fairly moot, but I wanted to take the time to address that since it hasn’t already been addressed.

3 Likes