Having a NaN value causing PlayerList value filter to break

As a developer of Vehicle Tycoon , we did an event where admin abuse come in priority. Our head admin just edited my stat for fun to try out our brand new admin system but the following just happened.


Reproduction: Edit stat to infinite then to Nan

System Information:
Windows 11 Pro 24H2

Expected behavior

Normal Behavior:
Inf> 2M > 0 > -1

The Player gui should put the nan value on top or on the bottom of the player list.

1 Like

@MagicLuau we will investigate soon, given this thread has not been looked at in a while we would like to know if the issue is still reproducible/relevant by you?

The issue is currently still up and reproducible

Performing an impossible mathematical operation will return NaN value, at example dividing 0 by 0. But a NaN value is still type of number in Luau. That means you can preform any math operations with a NaN value, but any of them will return NaN. Also performing less operator “<” and less or equal operator “<=” will return false, no matter how you compare them. This is what could have caused the error in sorting algorithm.

local nan = 0/0
print(nan <= math.huge)		-- Output: false
print(nan > math.huge)	 	-- Output: false

Currently I was researching about NaN value and found out, that performing equal operator “==” on any non-NaN value with itself, at exmaple 1 == 1, will return true, expect NaN value.

local nan = 0/0      -- One of the ways to get NaN value, you can also try tonumber("nan")
print(nan == nan)    -- Output: false

This is the only way how to detect a NaN value I found, but if you have systems that requires number input from client like admin abuse or cheaters, I recommend to check for a NaN value.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.