Throttle Value dividing it with trains maxspeed then the throttle percentage moves 0 - 100%

Here im wanting it so the trains maxspeed configuration attribute divides so the throttle gui when holding the keybind “a” will go from 0-100%

ive got the GUI and “a” keybind and actual train moving. i just cant seem to figure out how to get it so the maxspeed displays so whatever the maxspeed is set to it divides it to equal 100 on the gui then as the keybind “a” is pressed the throttle goes up so the gui slowley goes from 0 - 100% as the train also picks up speed

GUI:
image

current configuration:
image

i have no idea how’d i achieve this expcept dividing it with numbers maths and yeh no idea.

if need more screenshots or more detail just say!!

The maths is pretty straightforward.
The current speed divided by the maximum speed gives you a number between 0 and 1, multiply this by 100 and you get a percentage.
The math.round is just to give a whole integer e.g. 12% rather than 12.3456789%

textlabel.Text = math.Round((speed / maxspeed) * 100)
2 Likes