Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do i convert the seconds to minutes and seconds?

local StarterGui = game:GetService("StarterGui"):WaitForChild("TimerGui").TimerDisplay
local part = game.Workspace.Walls:FindFirstChild("BorderPart")
local roundLeg = 270
local intermessionLength = 10
local inRound = game.ReplicatedStorage.InRound
local Status = game.ReplicatedStorage.Status
local player = game.Players.LocalPlayer
local lobby = game.Workspace:WaitForChild("Floor")

inRound.Changed:Connect(function()
	wait(1)
	if inRound.Value == true then	
		part.Transparency = 1
		part.CanCollide = false
		part.SurfaceGui.TextLabel.Visible = false
	else
		part.Transparency = 0.2
		part.CanCollide = true
		part.SurfaceGui.TextLabel.Visible = true
		for _, v in pairs(game.Players:GetChildren()) do
			local char = v.Character
			char.HumanoidRootPart.CFrame = lobby.CFrame
		end
	end
end)

local function roundTimer()
	while wait() do
		for i = intermessionLength, 1, -1 do
			inRound.Value = false
			wait(1)
			Status.Value = "Intermission: ".. i .." seconds left!"
		end
		
		for i = roundLeg, 1, -1 do
			inRound.Value = true
			wait(1)
			Status.Value = i
		end
	end
end

spawn(roundTimer)

i tried all tutorials on yt but it only makes it worse

1 answer

✓ Accepted answer

You could divide the timer by 60 seconds (which is equal to a minute) and use the modulus operator (basically gets the remainder in division) to get the seconds.

local StarterGui = game:GetService("StarterGui"):WaitForChild("TimerGui").TimerDisplay
local part = game.Workspace.Walls:FindFirstChild("BorderPart")
local roundLeg = 270
local intermessionLength = 10
local inRound = game.ReplicatedStorage.InRound
local Status = game.ReplicatedStorage.Status
local player = game.Players.LocalPlayer
local lobby = game.Workspace:WaitForChild("Floor")

inRound:GetPropertyChangedSignal("Value"):Connect(function()
	task.wait(1)
	if inRound.Value == true then   
		part.Transparency = 1
		part.CanCollide = false
		part.SurfaceGui.TextLabel.Visible = false
	else
		part.Transparency = 0.2
		part.CanCollide = true
		part.SurfaceGui.TextLabel.Visible = true
		for _, v in pairs(game.Players:GetPlayers()) do
			local char = v.Character or v.CharacterAdded:Wait()
			char:PivotTo(lobby:GetPivot())
		end
	end
end)

local function roundTimer()
	while task.wait() do
		for i = intermessionLength, 1, -1 do
			inRound.Value = false
			task.wait(1)
			local secondsToMinutes = math.floor(i/60)
			local getRemainingSeconds = i % 60 -- or (i - (secondsToMinutes * 60))
			local timerFormat = "%i:i"
			Status.Value = "Intermission: ".. string.format(timerFormat, secondsToMinutes, getRemainingSeconds) .." left!"
		end

		for i = roundLeg, 1, -1 do
			inRound.Value = true
			task.wait(1)
			Status.Value = i
		end
	end
end

task.spawn(roundTimer)

In line 34, replace the string with "%i:% 0 2i" without the spaces.

1 comment

0

gogle fun

This discussion is preserved as it was. New answers, comments, and votes are closed.