How can i script the output of a slider so that when it is at 10 it will equal 0.2 and when it is at 0 it will equal 5
Maybe
Output = (Output * 50) + 5
(.2 * 50) + 5 = 10
(0 * 50) + 5 = 5
(.2 * 5) + 5 is 6, not 10.
0.2 * 5 = 1, 1+5 = 6
Simple to solve for the equation that represents the points.
You have (10, 0.2)
You have (0, 5)
find slope:
(0.2 - 5) / (10 - 0) = -0.48
find y-int: (you have it, but lets go through it for a generalization)
-0.48(0) + b = 5; b = 5
y = -0.48x + 5
-0.48(10) + 5 = 0.2
-0.48(0) + 5 = 0
Therefore,
local SliderOutput = InputValue * -0.48 + 5
how can i make it so 0 = 2 i think 5 is to high and you have to put the thing really up far for it to go fast and i would prefer it to be easier to make it fast
It’s the same process as before.
You still have (10, 0.2)
You now have (0, 2)
Solve for the line that crosses through the two points.
- Find the slope
- Find the y-intercept
- Put information together
Lets do it together
-
Finding the slope:
slope = (y1 - y2) / (x1 - x2)
slope = (0.2 - 2) / (10 - 0)
slope = -0.18
-
Finding the y-intercept:
y = -0.18x + b
;b
is the y-intercept; findb
; we can substitute a point in to solve for it.
2 = -0.18(0) + b; 2 = 0 + b; b = 2
(If you’re clever you will realize that when given a position, if the x-coordinate is 0 then the y-intercept will be equal to the y-coordinate of that point.)
- Putting the information together:
y = -0.18x + 2
Therefore:
local SliderOutput = InputValue * -0.18 + 2
Thanks i now understand how to calculate this and will now use it in all my other scripts