How would I make a top 100 leaderboard erase all data after timer hits 00:00:00

Example:
There are 100 players stored on the leaderboard and the time hits 00:00:00 how would I erase the data while being in-game and make it save the new data?

1 Like

Is there a gui on the screen that shows how much longer there is left on the timer?

No its a textlabel on a surface gui

Perhaps you could do something like this, but first reference the Gui and all. You can get the Gui from a random player, since the time displayed should be the same for all players. Include this in a loop:

if Gui.TextLabel.Text == "00:00:00" then
    for i,v in pairs(game.Players:GetPlayers()) do
        v.leaderstats.Score.Value = 0 --If your leaderboard statistics value is called 'Score', if not change it respectively.
    end
end

I think this would work. What do you mean by “save the new data” though?

Like it would save the new list onto a datastore

What do you mean “new list”? So we have A, the list before the leaderboard is cleared; and B, the list after it’s cleared (all would be 0). Which are you referring to?

game:Destroy() (30 Char…)

I’m just trying to figure out how I would have people on a datastore heres an example:
image
Then when the timer hits 00:00:00 I want to remove all the players on the list and then save the list with no players onto the datastore

Use a new key maybe? Like if your datastore is called “MyDataStore1” then once the timer hits zero, make the key used be “MyDataStore2”

Would RemoveASync() possibly work?

Also here’s the part of the script i use to get the player from the saved list
idk if this will help any or at all

function metaData:getTopHundred()
	local globalData = {};
	local data = metaData:getSortedDataStore();
	local page = data:GetSortedAsync(false, 100);
	page = page:GetCurrentPage();
	
	for key, value in next, page do
		local player = players:GetPlayerByUserId(value.key);
		globalData[#globalData + 1] = {player, value.value}; -- value.value = player value
	end
	
	return globalData;
end