I've created a table for a level system
local Levels = {
--XP is the data we are comparing
[0] = {1,0,10},
[10] = {2,10,20},
[20] = {3,20,30},
[30] = {4,30,40},
[40] = {5,40,50},
[50] = {6,50,60},
[60] = {7,60,70},
[70] = {8,70,80},
[80] = {9,80,90},
[90] = {10,90,100},
[100] = {11,100,110},
[110] = {12,110,120},
[120] = {13,120,130},
[130] = {14,130,140}
}
return Levels
The problem is that when comparing a value that is not in the table, for example 8, it gives a error, what I want to do is to create a range. Example:
local Levels = {
[NumberRange.new ( 0, 10 )] = {1,0,10},
--I don't know if NumberRange is compatible with tables but I want to do something similar
So that if the value is 0,1,2,3,4,5,6,7,8,9 or 10, it should return {1,0,10} And the same with the others values.
Can someone tell me a way to do that?
Tell me if you want me to send you the other scripts wich depends on this module script . Thanks in advance

8 comments
Thanks a lot dude!, this is really useful!
Also, It works with the key=0 and then it gives the following error ServerScriptService.LevelSystem.LevelSystemAPI:18: attempt to index local 'key' (a number value)
Which one is line 18 in your script?
Is line 3 in your script
Are you doing the ranges, or the [0], [10] thing for indexes?
I'm using [0],[10],...
Mine was written assuming the NumberRange.new thing.
Ok, thank you so much!