Anybody mind editing/rewriting my local script so that it shows my timer as minutes and seconds? I want it to show stuff like “1.00.00 and 1.05.00” not “60.00, 65.00” It’s for my obby and the timer works perfectly fine but I just want it to display regular stopwatch time. I’ve lost sanity and sleep over wrestling with this one script, i’ve tried everything even correcting the lines people in my other thread said to do but nothing works. Also I apologize about my grammar i’m just tired man. Script below:
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)
Brother the thing is I have no idea where to put anything. Im burnt out from working on the game and I hope somebody could just rewrite the script how I described I wanted it. I’m new to deving and scripting and this has been giving me a headache from hell all week
Preciate you man, the timer works marvelously and so does the start and stop part but it’s just I want the seconds displayed as minutes as time goes on. I just wish everything after “59.00” changes to the “1.23.45” format because today somebody told me that they beat my game in “2900.000 seconds” I was like WHAT?
Are you looking for hours or milliseconds? Some math could be done.
local function convert(Seconds)
local function format(Int)
return string.format("%02i",Int)
end
local Minutes = (Seconds - Seconds%60)/60
Seconds = Seconds - Minutes*60
local Hours = (Minutes - Minutes%60)/60
Minutes = Minutes - Hours*60
return string.format("%s : %s : %s",format(Hours),format(Minutes),format(Seconds))
end
Here is what I have gotten done: (in a server script)
local players = game:GetService("Players")
players.PlayerAdded:Connect(function(player)
local timeFolder = Instance.new("Folder")
timeFolder.Name = "Time"
timeFolder.Parent = player
local seconds = Instance.new("NumberValue")
seconds.Name = "Seconds"
seconds.Value = 0
seconds.Parent = timeFolder
local minutes = Instance.new("NumberValue")
minutes.Name = "Minutes"
minutes.Value = 0
minutes.Parent = timeFolder
end)
local RunService = game:GetService("RunService")
local counter = 0
RunService.Heartbeat:Connect(function(step)
counter = counter + step
if counter >= 1 then
counter = counter - 1
for i,v in pairs(game.Players:GetChildren()) do
local seconds = v.Time.Seconds
local minutes = v.Time.Minutes
seconds.Value += 1
print(v.Name.. " Has been playing for ".. minutes.Value.. " Minutes and ".. seconds.Value.. " Seconds")
if seconds.Value > 61 then
seconds.Value = 0
minutes.Value += 1
end
end
end
end)
Edit: all it does is counts seconds and minutes then prints it out to the output
Alright I’ll make a serverscript for the first script! Also how if you scroll up to the script I had above in the primary post thing can you tell me what and where I need to edit stuff? I apologize if im asking for so much but Im just new to all this and its gonna make my brain explode soon