I would love to implement a leaderboard into my lobby with every users fastest time completing my whole parkour map… just don’t know how to script it or where to start…
what I’m thinking is a part on level 1 that starts a timer, going + and then a part at the end of map that stops timer… that part seems tricky but I think I could tackle it… I just don’t understand how Its possible to track it on a leaderboard part like “Fastest Players All Time”
can someone tell me where I could start or if this even is feasible.
If I’m understanding you correctly, this is very simplisitic. Just assign the Text property of your TextLabel:
textLabel.Text = tostring(endTime);
endTime is a number henceforth it must be tostring’d so it can be used for the Text property.
If you’re wanting to save all time records, you should use an OrderedDatastore and save their endTime under their UserId as the key.
When displaying the leaderboard, use GetSortedAsync and use the first DataStorePage. There’s methods under the Players service for getting their username / thumbnail from their UserId if that is needed.
this is exactly what I’m looking for! I’m glad you labeled as simple cause I thought this was going to be difficult. thanks for writing out steps I should take. BIG thanks!
how would I set this up to get this onto a part… I tried some things but nothing was working… should I just set this up in a starter GUI to make a visible timer as well??
if you want it to finish when you touch a part, you might need a debounce so it doesn’t bug the GUI
local debounce = false
local gui = (GUIPATH)
local textlabel = gui.Text
local endpart = (PART TO BE TOUCHED PATH)
local startpart = (START PART TO BE TOUCHED PATH)
local startTime
local endTime
startpart.Touched:Connect(function(person)
if person:IsA("Part") and person.Parent:FindFirstChild("Humanoid") and game.Players:GetPlayerFromCharacter(person.Parent) and not debounce then --checks if it is a player
debounce = true
startTime = tick()
wait(cooldown)
debounce = false
end
end)
endpart.Touched:Connect(function(person)
if person:IsA("Part") and person.Parent:FindFirstChild("Humanoid") and game.Players:GetPlayerFromCharacter(person.Parent) and not debounce then
debounce = true
endTime = tick() - startTime
textlabel.Text = tostring(endTime)
wait(cooldown)
debounce = false
end
end)
would love to mark as solution but I’m not following, after testing around with this script I can’t get it to do anything… just putting this inside StarterGui or inside a frame with text transform the text into 00:00 I am confused more so than when I started lol
Hello I have tryed the time code and it’s good,
Almost what I am looking for.
How would you make the stopwatch display the current elapsed time
Until it stops at the finish
Would end Time have to be stored as a
number. Value to use it in a global leaderboard for datastore
Any help would be appreciated I have been trying to solve this for a week
Cheers