volume >= 0
Runs if the volume is greater than 0.
volume < 0
Will run if 0 is greater than the volume, which will never happen since the volume cannot be negative.
volume >= 0
Runs if the volume is greater than 0.
volume < 0
Will run if 0 is greater than the volume, which will never happen since the volume cannot be negative.
Your not doing that though
if (volume >= 1) then
print(volume.." is higher or equal to 1")
volume = 0
elseif (volume >= 0) then
print(volume.." is lower than 1")
volume += 0.1
end
``` you didn't even check if the thing thats greater than 0 is lower than 1
if (volume >= 1) then
print(volume.." is higher or equal to 1")
volume = 0
elseif (volume >= 0 and < 1) then
print(volume.." is lower than 1")
volume += 0.1
end
if (math.floor(volume) >= 1) then --// Checks if the volume is greater or equal to 1
print(volume.." is higher or equal to 1")
volume = 0
elseif (math.floor(volume) >= 0) then --// If its not greater or equal to 1, it will then check if it's greater than 0.
print(volume.." is lower than 1")
volume += 0.1
end
Theres no point to check if its lower than 1 since it’s obviously lower than one since the first compare returned as false
Oh yeah thats true idk whats wrong then
There are plenty of ways to approach this sort of method. You could store the volume somewhere in an IntValue, use n = n - (n % 1) to get rid of any loose decimal numbers each time you change the volume, or take a different approach with your conditional statements.
I personally think @JarodOfOrbiter has the best approach:
This is not only the easiest method to understand (arguably), but it’s also shorter and faster to apply than any of the methods I’ve listed above.
if (volume >= 1) then
print(volume.." is higher or equal to 1")
volume = 0
else
print(volume.." is lower than 1")
volume += 0.1
end