Modifying a slider output vale

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

1 Like

(.2 * 5) + 5 is 6, not 10.

0.2 * 5 = 1, 1+5 = 6

2 Likes

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
1 Like

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.

  1. Find the slope
  2. Find the y-intercept
  3. Put information together

Lets do it together

  1. Finding the slope:
    slope = (y1 - y2) / (x1 - x2)
    slope = (0.2 - 2) / (10 - 0)
    slope = -0.18

  2. Finding the y-intercept:
    y = -0.18x + b; b is the y-intercept; find b; 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.)

  1. Putting the information together:
    y = -0.18x + 2

Therefore:

local SliderOutput = InputValue * -0.18 + 2
1 Like

Thanks i now understand how to calculate this and will now use it in all my other scripts