I am trying to make a FOV slider with boundaries from 45 to 95 but there is a problem currently while trying to update the slider to a default value (being 80).
(Variables used in the code)
Min = 45
Max = 95
Here is my code (The issue is in the CalculateScale function):
Results:
0.2796 is much lower than it should be
somehow it calculates 58 as opposed to 80, obviously there is a fault in my maths but I don’t know what it is.
If you want someone’s help don’t try and make their life harder, take every screenshot of a code and paste it as an actual code with this . This way we can copy-paste it to the studio and debug it.
If we want to place your code in a test project and debug it, we will have to copy it from an image which is not as convenient as taking it from a code section.
For example:
Copying this to my project
local minValue = 45
local maxValue = 95
local delta = maxValue - minValue
local function ValueToScale(value)
local scale = (value - minValue) / delta
return math.clamp(scale, 0, 1)
end
local function ScaleToValue(scale)
local value = scale * delta + minValue
return math.clamp(value, minValue, maxValue)
end