#RNG

1 messages · Page 1 of 1 (latest)

restive karma
#

i recently started learning scripting and i dont really know alot, so my question is this the right method to do an RNG?

local Roll = script.Parent
local RarityLabel = script.Parent.Parent.rarity

Roll.MouseButton1Click:Connect(function()
local rng = Random.new()
local RandomNumber = rng:NextInteger(1,1000)
print(RandomNumber)
if RandomNumber >=1 and RandomNumber <= 400 then
RarityLabel.Text = "Common"
elseif RandomNumber >=401 and RandomNumber <= 600 then
RarityLabel.Text = "Rare"
elseif RandomNumber >=601 and RandomNumber <= 800 then
RarityLabel.Text = "Epic"
elseif RandomNumber >=801 and RandomNumber <= 950 then
RarityLabel.Text = "Legendary"
elseif RandomNumber >=951 and RandomNumber <= 1000 then
RarityLabel.Text = "Mythical"
end
end)

cold glen
#

works but is very ugly tbf

#

Create a table with the values and a weight and then generate a random number and compare it with the weight

#

there are rng system tutorials or kits you can take a look at

#

dont copy but use similair code which you understand