Some Help with Leaderstats

Hello. I need some help with my leaderstats system.

So basically, I have created a game with two different leaderstat values: Kills and Stages

My issue is that for some reason, the kills is always in front of the stages when showed on the server leaderboard. No matter what I do, it just doesn’t swap places. Here’s a screenshot.

How do I make it so that the Stages value is in front of the Kills? Or is it impossible? Please reply if you know the answer. Thank you for your time.

It would be better if you provide your code handling the leaderstats.

Of course, this is possible. It would be better if you share the code. I can review it and present it to you in edited form.

Did you write them both in one script or as two scripts?

Yes it’s possible but it would be better if you share the code

First is Stage (front) and second are kills. (With Saving) I don’t know how to say it so I wrote a script.

local StageStore = game:GetService("DataStoreService"):GetDataStore("StageData")
local KillStore = game:GetService("DataStoreService"):GetDataStore("KillData")

game.Players.PlayerAdded:Connect(function(plr)
	local leaderstats = Instance.new("Folder", plr)
	leaderstats.Name = "leaderstats"
	
	-- First
	local Stage = Instance.new("IntValue", leaderstats)
	Stage.Name = "Stage"
	Stage.Value = StageStore:GetAsync(plr.UserId) or 0
	
	-- Second
	local Kills = Instance.new("IntValue", leaderstats)
	Kills.Name = "Kills"
	Kills.Value = KillStore:GetAsync(plr.UserId) or 0
	
	Stage.Changed:Connect(function()
		StageStore:SetAsync(plr.UserId, Stage.Value)
	end)
	
	Kills.Changed:Connect(function()
		KillStore:SetAsync(plr.UserId, Kills.Value)
	end)
end)

I believe it’s impossible, iirc Roblox’s Leaderstats are sorted by alphabetical order, so you’d have to make a custom leaderboard script to bypass this unfortunately.

Scripts are read from top to bottom.