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

How to turn seconds into minutes and seconds? (00:00)

Asked by 1 year ago

Hello. I have recently been making a game with a round system. The game works fine and everything, though I only have one "issue".

The seconds left of the round (on the GUI) are only in seconds. I want it to say how many minutes and seconds (like the 00:00 format) the round has left. Here's the round script:



local roundLength = 1805 local intermissionLength = 40 local InRound = game.ReplicatedStorage.InRound local Status = game.ReplicatedStorage.Status local LobbySpawn = game.Workspace.LobbySpawn local GameAreaSpawn = game.Workspace.GameAreaSpawn InRound.Changed:Connect(function() wait(1) if InRound.Value == true then for _, player in pairs(game.Players:GetChildren()) do local char = player.Character char.HumanoidRootPart.CFrame = GameAreaSpawn.CFrame end else for _, player in pairs(game.Players:GetChildren()) do local char = player.Character char.HumanoidRootPart.CFrame = LobbySpawn.CFrame end end end) local function roundTimer() while wait() do for i = intermissionLength, 1, -1 do InRound.Value = false wait(1) Status.Value = "Game starts in ".. i .."..." end for i = roundLength, 1, -1 do InRound.Value = true wait(1) Status.Value = i end end end spawn(roundTimer)

As you see, I would like the 1805 seconds to be turned into 30:05 minutes. I'm not sure where to put the code, nor how to script it.

Any help is appreciated!

0
When you do 1805 ÷ 60, it output around 30.083, flooring it would give you 30 which is in minutes, and 1805 % 60 would be 5, and that's in seconds Xapelize 2658 — 1y
0
RainDroutz's reply worked perfectly! Thank you for helping me. armangaming4 0 — 1y

Answer this question