WaterWaveSize value is slightly different to what it is set at

I made a script what only runs if WaterWaveSize = 0.05 but it wasn’t running so I made it print the value first and it prints 0.05000000074505806 when its set to 0.05 why is this

If I recall correctly, this is due to the way that programming languages store decimal values. They are not precise when it comes to small decimals. This is a post from Quora about this topic: https://www.quora.com/Why-is-0-1+0-2-not-equal-to-0-3-in-most-programming-languages

1 Like

Try truncating the WaterWaveSize value when reading it.

local function truncateToHundredths(x)
    return x-x%0.01
end

if truncateToHundredths(WaterWaveSize) == 0.05 then
    print('do thing')
end

Nothing else you can really do.

1 Like