How to format time (Minutes:Seconds)?

Im trying to find how to convent seconds into minutes on my time counter gui, but i cant find how to do it. If you could help, i would appreciate it.


local ReplicatedStorage = game:GetService("ReplicatedStorage")

local TextLabel = script.Parent.time



ReplicatedStorage.Time.Changed:Connect(function(newTime)
	TextLabel.Text = newTime
end)

if TextLabel.Text == 60 then
	TextLabel.Text = "1:".. newTime
	
	
end
1 Like

Try this:

local function toMS(s)
	return string.format("%02i:%02i", s/60, s%60)
end
TextLabel.Text = toMS(newTime)

Also please research before posting, there are numerous ways to do this on google

1 Like

thanks you, but as i said i cant find one that goes with mine, because alot of them are based on a already set timer

I did this, but it doesnt work.



local ReplicatedStorage = game:GetService("ReplicatedStorage")

local TextLabel = script.Parent.time



ReplicatedStorage.Time.Changed:Connect(function(newTime)
	TextLabel.Text = newTime
end)

local function toMS(s)
	return string.format("%02i:%02i", s/60, s%60)
end
TextLabel.Text = toMS(newTime)

You need to do that for every time the time changes:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local function toMS(s)
	return string.format("%02i:%02i", s/60, s%60)
end

local TextLabel = script.Parent.time

ReplicatedStorage.Time.Changed:Connect(function() -- this doesnt return an argument
	TextLabel.Text = toMS(ReplicatedStorage.Time.Value)
end)

TextLabel.Text = toMS(ReplicatedStorage.Time.Value)
3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.