Need Help With A Global Leaderboard

I’ve gone through countless forum posts and been through many ‘solutions’ that don’t resolve my issue, so maybe someone can help me here lol

I need to create a Global Leaderboard for certain stats within the game; simple right? wrong. ( at least with the way I save my data )

I save all of my data within one data store, under one key ( e.g ‘Stats_3$*1!’ )

All of the data saved within the data store is saved within different ‘categories’ ( different tables )

e.g

	leaderstats = {
		{Name = "Bubbles", Value = 0},
		{Name = "Crystals", Value = 0},
		{Name = "Prestige", Value = 0},
	},

	BubbleData = {
		{Name = "BubbleCooldown", Value = 1.5},
		{Name = "TotalBubbles", Value = 0},
		{Name = "BubblesPerBlow", Value = 1},
		{Name = "Multiplier", Value = 1},
		{Name = "BubbleValue", Value = 1},
		{Name = "BubbleCapacity", Value = 10},
		{Name = "CrystalValue", Value = 1},
		{Name = "CrystalMultiplier", Value = 1},
		{Name = "TotalCrystals", Value = 0},
		{Name = "AutoBlow", Value = 0},
		{Name = "BubblesPopped", Value = 0},
		{Name = "GoldBubbleChance", Value = 5},
		{Name = "EquippedBubble", Value = "Blue"},
		{Name = "TimePlayed", Value = 0},
	},
	
	InventoryData = {
		{Name = "Blue", Value = true},
		{Name = "Green", Value = false},
		{Name = "Red", Value = false},
		{Name = "Purple", Value = false},
		{Name = "UFO", Value = false},
		{Name = "RedSlime", Value = false},
		{Name = "RedHeart", Value = false},
		{Name = "PurpleFlower", Value = false},
		{Name = "PurpleHeart", Value = false},
		{Name = "PinkFlower", Value = false},
		{Name = "PalmTree", Value = false},
		{Name = "GreenSlime", Value = false},
		{Name = "GreenFlower", Value = false},
		{Name = "GreenHeart", Value = false},
		{Name = "GoldFlower", Value = false},
		{Name = "Flower", Value = false},
		{Name = "EvilSlime", Value = false},
		{Name = "Cactus", Value = false},
		{Name = "BlueSlime", Value = false},
		{Name = "BlueHeart", Value = false},
		{Name = "YellowDuck", Value = false},
		{Name = "SpecialKraken", Value = false},
		{Name = "RedKraken", Value = false},
		{Name = "RedDuck", Value = false},
		{Name = "OrangeFrog", Value = false},
		{Name = "GreenFrog", Value = false},
		{Name = "GreenDuck", Value = false},
		{Name = "BlueFrog", Value = false},
		{Name = "GreenKraken", Value = false},
		{Name = "Sun", Value = false},
	},
	
	LevelData = {
		{Name = "Level", Value = 1},
		{Name = "XP", Value = 0},
		{Name = "Multiplier", Value = 1},
	},
	
	UpgradeData = {
		{Name = "Tapper", Value = 0},
		{Name = "Gold Tapper", Value = 0},
		{Name = "Evil Tapper", Value = 0},
		{Name = "Wand", Value = 0},
		{Name = "Mining Away", Value = 0},
		{Name = "Bubble Potion", Value = 0},
		{Name = "Better Pick", Value = 0},
		{Name = "Paper Bag", Value = 0},
		{Name = "Bubble Potion+", Value = 0},
		{Name = "Golden Touch", Value = 0},
		{Name = "Bombs Away", Value = 0},
		{Name = "School Bag", Value = 0},
		{Name = "Watch", Value = 0},
		{Name = "Auto Wand I", Value = 0},
		{Name = "Mouse", Value = 0},
		{Name = "Gold Pick", Value = 0},
		{Name = "XTRA XP", Value = 0},
		{Name = "Mouse+", Value = 0},
		{Name = "Gold Bag", Value = 0},
		{Name = "Auto Wand II", Value = 0},
		{Name = "Golden Bombs", Value = 0},
		{Name = "Better Watch", Value = 0},
		{Name = "Mouse++", Value = 0},
	},
	
	Codes = {
		{Name = "Beta", Value = 0},
		{Name = "BUBBLES", Value = 0},
		{Name = "Sunny", Value = 0},
		{Name = "Chris Tal", Value = 0}
	}

When the game is loaded, those ‘categories’ ( the tables ) are instantiated as folders, with the respective stat values created within.

image

All of the data is saved within one data store to sorta avoid datastore overloading and crashing

Lets say I want to create a global leaderboard using OrderedDataStore, for the stat ‘Bubbles’. I’d have to retrieve the data from [“leaderstats”] and then [“Bubbles”]. I can’t do that with OrderedDataStores ( to my knowledge )

I’ve been trying to figure out how I’d do it, and I’ve tried countless methods but nothing has worked. I was wondering if someone knew HOW I’d go about retrieving the ordered data in my situation.

I’d be glad to answer any questions or clarification!
1 Like

Why wouldn’t you be able to? OrderedDataStores are extremely similar to normal datastores, with the only limitation being that the stored value has to be an integer. Assuming the value of Bubbles is an IntValue, there should be no issue accessing it from the leaderstats thing.

Right? That’s exactly what I thought, but when getting the OrderedDataStore of the key used, I don’t get a single page or entry, literally nothing…

You can’t, but, OrderedDataStores are the easiest option for leaderboards, because they handle all the ordering without any extra API requests or sorting on your side.

The way I see it, you will have to create separate OrderedDataStores for the different leaderboards, for example, BubblesLeaderboard, or CrystalsLeaderboard.

The other option of using a regular Datastore, just won’t be as efficient and will use up way more of your API budget. It would be possible, but I think it’s going to be more trouble than it’s worth.

Please provide your code if you want any help with it.

1 Like

That’s exactly what I’m doing haha, Thank you!

1 Like