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.
Quwanterz
(Quwanterz)
August 11, 2021, 11:23am
#2
It would be better if you provide your code handling the leaderstats.
Utk4_e
(Utk4_e)
August 11, 2021, 11:30am
#3
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
R05HX
(Rosh)
August 11, 2021, 11:49am
#5
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)
zQ86
(zQ86)
August 11, 2021, 12:04pm
#6
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.
R05HX
(Rosh)
August 11, 2021, 1:01pm
#7
Scripts are read from top to bottom.