--Script that makes light flicker and fade and whatever --Variables for objects local lightModel = script.Parent print(lightModel) local lightPart = lightModel.Light print(lightPart) local light = lightPart.SurfaceLight print(light) --Variables for light configurations are not usable, in my opinion --Found out that creating variables directly for a property, will get the number --But not the property itself. Just takes number. So you must manually edit, as it is below --Variables for a few amounts local LOWEST_AMOUNT = 0.1 local HIGHEST_AMOUNT = 1 --Smoothness is like how many times it loops local function fadeOutAndFadeIn(initialAmount, lowestAmount, smoothness, transitionSpeed) for currentAmount = initialAmount, lowestAmount, -smoothness do light.Brightness = currentAmount print(light.Brightness) wait(transitionSpeed) end for currentAmount = lowestAmount, initialAmount, smoothness do print(currentAmount) light.Brightness = currentAmount print(light.Brightness) wait(transitionSpeed) end end while true do fadeOutAndFadeIn(HIGHEST_AMOUNT, LOWEST_AMOUNT, 0.1, 0.1) wait() end
Ok firstly just ignore stupid comments just for me to keep some info and stuff to remember. Ok so basically, not much of a problem, but it irritates me. I want to know why, when the for loop goes down and up, it has many digits; like the number is very close to the expected one, but it is not, when looping down. For example, you would expect the first loop down to be 0.9, but the number would be like 0.8999.etc and whatever. I want to understand why this happens, and perhaps how to stop this from happening, WITHOUT manually rounding the numbers. Weirdly the current amount that is printed is accurate, just the brightness. Maybe this isn't too important, but it irritates me. Thanks in advance.