Hello, I want to make a global leaderboard that saves the player’s fastest time, then displays it on a global leaderboard surfacegui, from fastest to slowest. So far I made a local script that starts the tick timer, then when the player reaches this function, the timer ends and prints the time taken.
if objectives.HasKey.Value == true then
local timerEnd = tick() - gamestart
print(timerEnd)
game.ReplicatedStorage.TimePass:FireServer(timerEnd)
I’m using “ThatTimothy” sample for global leaderboards and edited his script like this
for i,plr in pairs(game.Players:GetChildren()) do--Loop through players
if plr.UserId>0 then--Prevent errors
local ps = game:GetService("PointsService")--PointsService
local w = game.ReplicatedStorage.TimePass.OnServerEvent:Connect(function(player, timerEnd)
print(timerEnd)
end)--Get point balance
if w then
pcall(function()
--Wrap in a pcall so if Roblox is down, it won't error and break.
dataStore:UpdateAsync(plr.UserId,function(oldVal)
--Set new value
return tonumber(w)
end)
end)
end
end
end
However I’m not seeing anything being saved onto the leaderboard. But both the client and the server do print the correct value for time taken. I’d appreciate any help I can get. Thank you.