Mixing numeric and string values in one column in leaderstats causes corescript errors

Mixing, for example, both IntValues and StringValues in a column with leaderstats causes the corescripts to error. It even fails to initialize entirely on one client.

Repro (2 players):

local p1 = game.Players.PlayerAdded:wait();
local p2 = game.Players.PlayerAdded:wait();

local ls1 = Instance.new("Model", p1);
ls1.Name = "leaderstats";
local ls2 = Instance.new("Model", p2);
ls2.Name = "leaderstats";

local v1 = Instance.new("IntValue", ls1);
local v2 = Instance.new("StringValue", ls2);
v1.Value = 1333337;
v2.Value = "fsdvcakjh sdfahkjvdazfxhjklfsda";

What I get:

Client 1

00:01:35.350 - CoreGui.RobloxGui.Modules.PlayerlistModule:352: attempt to compare number with string
00:01:35.351 - Stack Begin
00:01:35.351 - Script 'CoreGui.RobloxGui.Modules.PlayerlistModule', Line 352
00:01:35.351 - Script 'CoreGui.RobloxGui.Modules.PlayerlistModule', Line 689 - upvalue setEntryPositions
00:01:35.352 - Script 'CoreGui.RobloxGui.Modules.PlayerlistModule', Line 1100 - upvalue updateLeaderstatFrames
00:01:35.352 - Script 'CoreGui.RobloxGui.Modules.PlayerlistModule', Line 1205
00:01:35.352 - Stack End

Client 2

00:01:35.881 - CoreGui.RobloxGui.Modules.PlayerlistModule:352: attempt to compare string with number
00:01:35.881 - Stack Begin
00:01:35.882 - Script 'CoreGui.RobloxGui.Modules.PlayerlistModule', Line 352
00:01:35.882 - Script 'CoreGui.RobloxGui.Modules.PlayerlistModule', Line 689 - upvalue setEntryPositions
00:01:35.882 - Script 'CoreGui.RobloxGui.Modules.PlayerlistModule', Line 1100 - upvalue updateLeaderstatFrames
00:01:35.883 - Script 'CoreGui.RobloxGui.Modules.PlayerlistModule', Line 1408 - upvalue setupEntry
00:01:35.883 - Script 'CoreGui.RobloxGui.Modules.PlayerlistModule', Line 1422 - local insertPlayerEntry
00:01:35.883 - Script 'CoreGui.RobloxGui.Modules.PlayerlistModule', Line 1532
00:01:35.884 - Stack End
00:01:35.884 - Requested module experienced an error while loading
00:01:35.884 - Script 'Script Context.StarterScript', Line 34
00:01:35.884 - Stack End
00:01:35.926 - Requested module experienced an error while loading
00:01:35.926 - Script 'CoreGui.RobloxGui.CoreScripts/Topbar', Line 869 - local CreateSettingsIcon
00:01:35.927 - Script 'CoreGui.RobloxGui.CoreScripts/Topbar', Line 1338
00:01:35.927 - Stack End
00:01:35.927 - Requested module experienced an error while loading
00:01:35.928 - Script 'CoreGui.RobloxGui.Modules.PlayerDropDown', Line 40
00:01:35.928 - Stack End
00:01:35.928 - Requested module experienced an error while loading
00:01:35.928 - Script 'CoreGui.RobloxGui.Modules.Settings.SettingsHub', Line 55
00:01:35.929 - Stack End

It obviously messes up leaderstats even more when stuff actually happens, as the reordering flat out breaks now (such as player rows overlaying others). But obviously the error above causes it all.

Expected behavior is either all string values appearing above or all below the numeric ones (and they should probably be ordered properly too), obviously.

Why are you even mixing them?

There’s a gamepass for unlimited money, which should show "Unlimited" instead of a number in leaderstats.
Using strings for all values obviously breaks the ordering.

I’m not really up for creating my own leaderstats for just this, which will also take things like adding friends from leaderstats away.

You could wait until this is “fixed”, which might take a long time.
Or just use a StringValue for your numbers too…

Isn’t it like the intern time of the year? :sunglasses:

But using strings causes ordering to mess up heavily, making it a mess. (and I ducttaped this change into the game so badly that it’s a pita to change ;))

@Den_S

tab = {'1337', '1', '23', '1234', 'Unlimited'}

table.sort(tab, function(a,b) local a,b = tonumber(a), tonumber(b) if a == nil then return b == nil elseif b == nil then return a == nil else return a < b end end)

for _, v in pairs(tab) do
print(v)
end

Enjoy having ordering of all numbers then strings. I’m sure the sort function can be made better but this works. Tested it in Lua demo so enjoy the terrible indentation

The entire issue is that the Roblox leaderboards have internal ordering, which is something that does not “properly” order if numbers are strings (which can be expected) and entirely fails to behave with mixed values. As far as I know, I cannot directly manipulate that ordering.

What’s wrong with 1,333,337? :wink:

Not entirely sure what you’re trying to imply, but I was attempting to convey that since 23337 < 1333337, 23337 should appear below 1333337, but it doesn’t since “23337” > “1333337”.

Interestingly the leaderboard should also fail if the primary stat is a boolean too.

It probably fails for any 2 stats of a different type.

I mean if you only have bools in the primary stat. Below is what the current implementation attempts to do if the primary stat of 2 players arent the same.

print('a'>'b')
print(2>1)
print(true>false)

false
true
attempt to compare two boolean values

I noticed what you meant after I posted my last reply.
In the meantime, I’ve made this pull request to fix it:

The bools get mixed with the strings though, so a table of {‘z’, ‘a’, true} becomes {‘a’, true, ‘z’}

If you’re using a BoolValue and AnotherValue both for the same primary stat, you’re doing something wrong.

Some might argue that OP is using it wrong too, doesn’t mean it shouldn’t be catered to

Numbers VS booleans would always have numbers > booleans because how ASCII works.
Strings VS booleans would depend, but when working with strings, one might call “true”/“false” a string.

Exactly. The Core Scripts should be able to handle any parameter and not cause errors. No matter what headache it might cause to the person who has to go in and edit it.