Can't break this while loop!

ignore the do/then error

The loop should execute whenever the value is more than .5 and break if it is under .5. Connecting this to a switch, the loop does not break when the value’s changed under the requirement and instead overlays on itself when the value meets the requirement again.

If you want to you can just submit a working version of this as I’ve spent three days attempting to fix this code.

You put do instead of then in the if value <= .5

Implementing inverse values defuncts the code, making the loop play once and only when triggered again.

It would be

repeat
sp.light.Transparency = 0
sp.Light.Material = Enum.Material.Neon
-->> The whole code
until val <= 0.5

You should remove the while loop, and the statement inside of the loop.

Attempted to integrate the repeat before, tried your way and even put the loop inside the repeat. Loop could not be broken.

You are only checking the value that was passed into the function.

in the part “if val <= .5” you didn’t use then, you used do which is a syntax error.

I said specifically to ignore that error as I knew what was wrong. The screenshot was taken at a wrong time.