You can write your topic however you want, but you need to answer these questions:
-
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. -
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! -
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)