Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Converting TimeLength seconds into minutes..?

Asked by 9 years ago

I've come about this problem many times, I am trying to make and so called "TimeLength" bar, which means when a song textbutton is clicked, it plays the sound (already scripted). The problem is, I am trying to make it to on a bar it shows the length of the sound in minutes, ROBLOX currently has it in seconds so it would be 120 instead of "2:00". How is it possible to covert the seconds into minutes, place them on a textbox and making a frame move using tweensize to go with the music as the iPhone has.

If you didn't know what I mean by "tweensize to go with music as the iPhone as" its that bar that goes when the music plays, stops at the end, at the same time as the song."

Its very important that I can find this out fast, so please help if you can ;)

1 answer

Log in to vote
0
Answered by 9 years ago

To answer your question:

local num = 120 -- how many seconds at maximum

local sec = 0
local min = 0

while num > 60 do
    sec = sec - 60
    min = min + 1
end

sec = num

local maxsec = sec
local maxmin = min
local maxsec2 = num

local text = script.Parent.left
local text2 = script.Parent.max
local barholder = script.Parent.BarHolder -- this is the size of the bar
local bar = barholder.bar

text2.Text = "Song Length:" ..maxmin.. ":" ..maxsec

while wait(1) do
    if song.IsPlaying then
        sec = sec - 1
        if sec == 0 then
            min = min - 1
        end
        local sec2 = 0
        sec2 = (min * 60) + sec
        text.Text = "Time Left: " ..min.. ":" ..sec
        bar:TweenSize(UDim2.new((1/maxsec2)*sec2,0,1,0),"InOut","Quad",0.1,true)
    end
end

This should do it. Sorry, but I don't have time to explain. PM me if you have problems. I'm EmeraldSlash.

0
why did i get downvoted..? i most likely helped him, and I explained why I couldnt explain TheDeadlyPanther 2460 — 9y
0
I have no clue, but I pmed you on ROBLOX. UnleashedGamers 257 — 9y
0
Here, ill give you a like ;) UltraUnitMode 419 — 9y
0
Problem is occurring, the wait looks like its freezing/crash my studio and game. I PMed you on ROBLOX. UnleashedGamers 257 — 9y
0
ty, ultra. TheDeadlyPanther 2460 — 9y
Ad

Answer this question