Need help about rng system

Hello, i wanted to know how Sword Factory Games rng number work?
so i want to know how they generate random number from smallest to highest? like to get high number is rlly rare (example: 1/100k)

1 Like
print(math.random(1, 100000))

ssssss

1 Like

You could use the math function math.random . Which should look like this: math.random(x, y)
P.S. make sure the y is bigger than x.
How does it work? The code will pick a number between x and y.
Learn more at: math

i think not that bc on sfx can generate random number without max num

also if i do math.random(1, 100000) that gonna generate big number

bruh, that’s what rng is. how do you not understand. Also you can replace the y with math.huge to generate infinite numbers

are u dumb there limit for y in math.random, u cant use math.huge on y in random it will returned an error.

yeah ok, atleast explain what you want to achieve cuz i dont understand

i thought u wanted to know how to make rng. but apparently no.

I think, from what i’ve seen in a google search, It uses a weighted random generator, basically a table which contains a sword and a weight attached to It, To put simply, Bad sword are more common (“Early game”) . If you want to create this kind of random, then I suggest you to use Ranlib by spacecube

for example

local Ranlib = pathtoranlib
local rand = Ranlib.new()
local chanceDictionary = {
	Normal = 80,
	Uncommon = 10,
	Rare = 5,
	Unique = 3,
	Legendary = 2,
}
print(rand:NextChance(chanceDictionary))
1 Like

that chance im asking rng bruh.

if you want to get a random number from the minimum and to the max you want you have to do math.random(min, max)

rng is a random number generator basically it generates a random number from internal entropy source. This “chance” Is also an rng, but is biased towards a certain item.As it returns a certain key using a random number to select the index

1 Like

on sword factory they used number not % like 1/36,900 or 1/47.1 (higher num is harder) then that upgrader generate random number it self without max number. if the generated number is higher than the rng chance the item will be upgraded

you can just check if generated number is higher than the certain amount…

oh ok so lets determain 10 to be our first chance, the first noob sword will be 1/10 right??
then lets just define increment as 5 so itll be sorta like this

local firstswordchance = 10
local i = 5
local d = 5
local function check()
      local rand = math.random(firstswordchance -d,firstswordchance + i)
      if rand > firstswordchance then
      firstswordchance = rand
      upgrade()
     end
end

the higher you set i,d the more chance that the number will be higher than the first rarity
the lower you set d, if lower than i, after more upgrade ,it will be harder to upgrade.
DO NOT SET TO NEGATIVE
and this wont be op, as new player wont get lv 329410231213 sword but a high rank player with lv 999999999 wont get a number too low that they’ll have an eternity for upgrading