How do i get a number from Highest to Lowest?

Hello!
I have been making a slider for the background music, but i need to get a number from the
Highest to lowest / 0.5 to 0.
But i cant find a method to get that number, i tried using clamp, but in only calculates Minimum to Maximum.
Could any one help?

Thanks!

You can try to convert the music length into seconds (you can already do this with Sound.TimeLength [a read only number]).

Example, if y / y = 1, then the music have ended, whereas if x / y = 0.5, then it’d be halfway into the song.

So, I’d suggest making a value that gets changed for each sound that has been returned from the script. It would change the value into the full length of that audio. Then manipulate the TimePosition of the sound from the GUI, or whatever slider you’re using.

Like this:

local Slider = game.StarterGui.BGM.Slider -- I recommend the slider to be parented to another frame, and setting the X scale to 1 and the offset to 0; a lot more easier to manage.
local soundPack = game.StarterGui.BGM.Sounds:GetChildren() -- where ever the pack of sounds get imported to; we're using this as an example.

local musicPicked = soundPack[math.random(1, #soundPack)]
local musicFullLength

if musicPicked then -- would get the length of the music that was picked, then returns it to the musicFullLength
    
    musicPicked.TimeLength = musicFullLength
    -- more code here...
end

It may look messy right now, but this would be a general way of how you’d acquire the highest to lowest.

It also works for the volume as well if you know how to do that.