Seconds to minutes please!

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!
    I want to convert my timer from seconds to minutes in the script below.
  2. What is the issue? Include screenshots / videos if possible!
    When I try to convert my seconds to minutes nothing works and I’ve tried for the past week. I hope somebody can give me guidance!
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I’ve looked all over youtube and I even asked the forum here but nothing seems to work and I’m somewhat clueless about where to put everything because I’m fairly new to scripting! Also let me know if I need to create a folder in the developer hub because I can since I have my timed remoteevent named “BestTime” and I have my checkpoint sound that plays when you step on one of my checkpoints! Script below:
local currentTime = 0
local timerStopped = false
local Runservice = game:GetService("RunService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local personalBest = player:WaitForChild("PersonalBest") or math.huge
local replicatedStorage = game:GetService("ReplicatedStorage")

local textLabel = script.Parent
textLabel.Text = "Timer: " .. string.format("%.3f", currentTime) .. "\nPersonal Best: " .. string.format("%.3f", personalBest.Value)
personalBest.Changed:Connect(function()
	textLabel.Text = "Timer: " .. string.format("%.3f", currentTime) .. "\nPersonal Best: " .. string.format("%.3f", personalBest.Value)
end)

function onStartTouched(hit)
	timerStopped = false
	startTime = tick()
	currentTime = 0
	Runservice.RenderStepped:Connect(function()
		if not timerStopped then
			currentTime = tick() - startTime
			textLabel.Text = "Timer: " .. string.format("%.3f", currentTime) .. "\nPersonal Best: " .. string.format("%.3f", personalBest.Value)
		end
	end)
end

function onEndTouched(hit)
	if not timerStopped then
		timerStopped = true
		if currentTime > 0 and currentTime < personalBest.Value then
			personalBest.Value = currentTime
			replicatedStorage.BestTime:FireServer(currentTime)
		end
		textLabel.Text = "Timer: " .. string.format("%.3f", currentTime) .. "\nPersonal Best: " .. string.format("%.3f", personalBest.Value)
	end
end

workspace:WaitForChild("StartTimer").Touched:Connect(onStartTouched)
workspace:WaitForChild("EndTimer").Touched:Connect(onEndTouched)
2 Likes

you can try to use this snippet down below

local mins = 0
local secs = 95 -- seconds here

while not (secs-60<0) do
mins = mins + 1 -- adds minutes
secs = secs - 60 -- subtracts seconds
output = mins.."m"..secs.."s"
end

print(output) -- outputs 1m35s

Code Snippet

Hope this helps!

Wait where do I put it? Between, after or before which lines? :sob:

After. Cause you want to convert the time after ending the timer

Alright 2 questions:Do i delete any of my code? And where do I put this code, after what section? I apologize for all the questions im a new dev and im curious

You don’t need to remove all of your code, it’s just code for converting

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