This is intended behaviour, NaN is a number in Lua. If this is causing problems for you, check that n ~= n where n is the number that is being inputted. NaN is not equal to anything, not even itself.
Pretty sure this is intentional, as even though its called ‘not a number’ it still is a number. Doing tonumber("inf") also produces a number which is intentional.
If you need to check if a value is nan to prevent spoofing you can do the following:
local example = (0 / 0)
if (example ~= example) then
print(`{example} is NaN`)
end
RemoteEvent.OnServerEvent:Connect(function(Player, Name, Value, Percent)
if typeof(Name) ~= "string" then
warn("Invalid 'Name': expected string, got", typeof(Name))
return
end
if typeof(Value) ~= "string" and typeof(Value) ~= "number" and typeof(Value) ~= "boolean" then
warn("Invalid 'Value': expected string, number, or boolean, got", typeof(Value))
return
end
if typeof(Percent) ~= "number" or Percent < 0 or Percent > 1 then
warn("Invalid 'Percent': expected a number between 0 and 1, got", Percent)
return
end
print(Player.Name .. " updated settings with Name: " .. Name .. ", Value: " .. tostring(Value) .. ", Percent: " .. Percent)
end)
While this might be surprising, Luau numbers can contain an infinity or a NaN values and these are their textual representations.
This behavior is intentional and existing code relies on it.