How do i convert seconds into into minutes for this timer?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    Im making a game that has a game loop that has a round timer kept in a string value and i am wondering how i can show that time in minutes instead of seconds.
  2. What is the issue? Include screenshots / videos if possible!
    I have no idead how to do that

any help would be appreciated! here’s the code:

GameLoop module:

local Players = game.Players:GetChildren()
local ServerStorage = game:GetService("ServerStorage")
local Teams = game:GetService("Teams")
-- Varibles
local Maps = ServerStorage.Maps:GetChildren()
local SelectMap = Maps[math.random(1, #Maps)]
local TeleportsRound = SelectMap.TeleportRound:GetChildren()
local KillerTeleport = SelectMap.KillerTeleport:FindFirstChild("Telepart")
local LobbySpawn = workspace.Lobby.LobbyTele
local Killer = Teams.Killer:GetPlayers()
local Victims = Teams.Victims:GetPlayers()
-- Module
local RoundManager = {}

function RoundManager:TeleportVictims()
	SelectMap.Parent = workspace
	for _, Victim in pairs(game.Teams.Victims:GetPlayers()) do
		local character = Victim.Character or Victim.CharacterAdded:Wait()
		character.HumanoidRootPart.CFrame = TeleportsRound[math.random(1, #TeleportsRound)].CFrame
		end
	end

function RoundManager:TeleportKiller(killer)
	local Killercharacter = killer.Character or killer.CharacterAdded:Wait()
	Killercharacter.HumanoidRootPart.CFrame = KillerTeleport.CFrame
	print(killer)
end

function RoundManager:CleanupRound()
	SelectMap.Parent = ServerStorage.Maps
	for _, player in pairs(game.Players:GetChildren()) do
		local character = player.Character or player.CharacterAdded:Wait()
		local humanoid = character:FindFirstChild("Humanoid")
		humanoid.Health = 0
			end	
		end

return RoundManager

GameLoop
```--Varibles
local Players = game:GetService("Players")
local RoundManager = require(script:WaitForChild("RoundManager"))
local replicatedStorage = game:GetService("ReplicatedStorage")
local Teams = game:GetService("Teams")
local Status = replicatedStorage.Values.Status
local Intermission = 25
local RoundTime = 300
local HidingTime = 30
local PlayersToStart = 2
local Knife = game.ServerStorage.Knife:Clone()
local KillerTeam = Teams.Killer
--Functions

function ChooseKiller(players)
	return players[math.random(1, #players)]
end


while wait(1) do
	
	
	for i = Intermission, 0, -1 do
		Status.Value = "Next Round Starts in: " ..i -- Intermission Timer
		wait(1)
	end
	local victims = game.Players:GetPlayers()
	local killer = ChooseKiller(victims)
	local Lobby = Teams.Lobby
	Status.Value = "The killer is... "
	wait(2)
	Status.Value = killer.Name.."!"
	wait(3)
	for i, v in pairs(Players:GetChildren()) do
		if v:IsA("Player") then
			v.Team = game.Teams.Victims
		end
		if v:IsA(killer) then 
			killer.Team = KillerTeam
		end
	end
 
	RoundManager:TeleportVictims()
	for i = 30, 0, -1 do
		Status.Value = "The killer comes in "..i.." seconds!"
		wait(1)
	end
	Knife.Parent = killer.Backpack
	RoundManager:TeleportKiller(killer)


	for i = RoundTime, 0, -1 do
		Status.Value = "Time left until the round ends: "..i
		wait(1)
	end
	
	
	
	RoundManager:CleanupRound()
	for i, v in pairs(Players:GetChildren()) do
		if v:IsA("Player") then
			v.Team = game.Teams.Lobby
			end
		end
	end


Scrpit that changes the GUI
```local replicatedStorage = game:GetService("ReplicatedStorage")
local Status = replicatedStorage.Values:WaitForChild("Status")
local Players = game.Players:GetChildren()
local Text = script.Parent.ScreenGui:WaitForChild("GameStatus")
Status:GetPropertyChangedSignal("Value"):Connect(function()
	Text.Text = Status.Value
end)

Google before asking questions.

This post might help. They format it HH:MM:SS
Seen here

If you want something like “X Minutes and X seconds” using words. You can do this by:

local Seconds = 130
local ConvertToText = " "..math.floor(Seconds / 60)).." Minutes, ".. Seconds -  math.floor(Seconds).." Seconds"
print(ConvertToText ) -- should work

But there is many methods to convert seconds into minutes, hours etc.

1 Like

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