Godbless you man. If silent’s script doesnt work im just gonna leave the timer how it is and ima just start on making the leaderboard for the record times so people can compete. Have a good night😎
I think I should change the name of the timergui and maybe the script?
First of all, the title must describe the issue. You can put that it’s paid in extras or the text part. Second, we cannot write scripts for you, but only advise you errors.
(Not trying to be rude, just trying to prevent you from getting flagged)
All this being said, at least try to learn the solution SomeFedoraGuy gave you, the forums aren’t a commission server, it’s a place to learn. If it’s too advanced, you can always look through other topics and solutions to see how other people made theirs!
You right, I just don’t understand how y’all can just easily go through this but then again y’all were new at one point too just like me. W mans
oh my god can you stop reposting and actually check your original post? also you don’t need to pay 100 robux just for some unemployed dude to answer your question for fun on a tuesday night.
anyways here’s the script
local currentTime = 0
local startTime = 0
local timerStopped = true
local Runservice = game:GetService("RunService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local personalBest = player:WaitForChild("PersonalBest")
local replicatedStorage = game:GetService("ReplicatedStorage")
local function secondsToMinSecMs(seconds)
local minutes = math.floor(seconds / 60)
local remainingSeconds = seconds % 60
local secondsSplit = math.floor(remainingSeconds)
local millisecondsSplit = math.floor((remainingSeconds - secondsSplit) * 100)
return string.format("%02i:%02i.%02i", minutes, secondsSplit, millisecondsSplit)
end
local textLabel = script.Parent
textLabel.Text = "Timer: " .. secondsToMinSecMs(currentTime) .. "\nPersonal Best: " .. secondsToMinSecMs(personalBest.Value)
personalBest.Changed:Connect(function()
personalBest.Value = math.clamp(personalBest.Value, 1/math.huge, math.huge)
-- if number is less than the smallest positive number possible (x <= 0)
-- then the line above will make number the smallest positive number possible (x ≈ 0, x > 0)
-- peventing personal best to be negative numbers or exactly 0
textLabel.Text = "Timer: " .. secondsToMinSecMs(currentTime) .. "\nPersonal Best: " .. secondsToMinSecMs(personalBest.Value)
end)
local function onStartTouched()
currentTime = 0
startTime = tick()
timerStopped = false
end
local function onEndTouched()
timerStopped = true
if currentTime < personalBest.Value then
personalBest.Value = currentTime
replicatedStorage.BestTime:FireServer(currentTime)
end
textLabel.Text = "Timer: " .. secondsToMinSecMs(currentTime) .. "\nPersonal Best: " .. secondsToMinSecMs(personalBest.Value)
end
Runservice.RenderStepped:Connect(function()
if not timerStopped then
currentTime = tick() - startTime
textLabel.Text = "Timer: " .. secondsToMinSecMs(currentTime) .. "\nPersonal Best: " .. secondsToMinSecMs(personalBest.Value)
end
end)
workspace:WaitForChild("StartTimer").Touched:Connect(onStartTouched)
workspace:WaitForChild("EndTimer").Touched:Connect(onEndTouched)
first thing i did is set up a converter that first divides the seconds by 60 seconds, then get the remainder of seconds/60 then the milliseconds then concatenate them together using string.format()
i also removed some things including math.huge
since you cant index Value
to a number
no need to give me robux i just did this for fun
I cant lie you funny as hell. Preciate the script, lemme go test it.
thank you for the compliment, also i made small changes in the code since i noticed a few errors earlier
It didn’t work, it just says label in test mode
Thanks for improving my code. I will have a look and see what I can do better with it next time
hold on lemme test it too rqrqrq
In all honesty I might as well just stick with the seconds timer since it can’t be fixed
Take your time, also I sent screenshots of how my gui and replicatedstorage were organized if you wanna scroll up just a little
i fixed it. my mistake was not changing the function name in some lines and something on the converter.
Oh, you mind slidin the script so I can test it as well?
here’s the script it’s in the original reply
For some reason it doesn’t work. Thank you for doing all you could to help though. Thank all of yall, I really appreciate it. But since I can’t fix the timer I’ll just stick with this one right here, the original script i had since its the only one that works without everything being ruined:
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)
Dude… IT WORKS. Thank you so sk so so so so much
ofc it works, i tested it in my roblox place
also can you please mark answer the original reply and not the “here’s the script it’s in the original reply” thank you
Hell yeah I got you! I really appreciate all of y’all for the help man. Im taking a break from working on the game til the first and then I can work on my leaderboard
you’re welcome
This text will be blurred