(SOLVED) How could I add multiple things to this?

So, I’ve been trying to make a spinning system and I’ve come across an issue, I have no idea how I could add multiple things to it. (sorta) This is my script:

while wait(.2) do
local num = math.random(1,100)

if num <= 2 then
	print("Legendary!")


elseif num <= 27 and num > 2 then
	print("Rare!")
	
elseif num <= 71 and num > 27 then
	print("Common!")
	end
end

Let’s say I wanted to add multiple things in each rarity group and they are all the same rarity obviously but I don’t know how I would do that, in summary I need help making a spinning system with multiple rarity groups. (But still keeping it something simple like this) And I’ve found a way to make a system with rarity easier than others but I wanna know how I could add multiple items to this spinning system in each rarity group (Example: Sword is common and so is a gun but a shotgun is rare and so is a dagger and they are each 10 percent)

1 Like
1 Like

for each sub group (say the <=27 and >2 you could have a random pick between 3 or 4 items.

Nevermind I was able to find a solution, thank you for your help though!

If you’ve solved it please explain the solution so others with the same question can get an answer if they search this post.

Oh okay, pretty much what I did was I made multiple tables for each rarity group (One for common one for rare y’know and they all contain what was in that rarity) Then I get a random number and detect if its between a certain two numbers for example rare would be equal to or lower than 35 but not more than 5 that would mean its a 30 percent chance so I just did that with each rarity. I knew how to detect if a rarity has been spun so if they got a common I would search through the common table I made a bit back and generate another random number to get a random member of that table. Ik I suck at explaining but if you want just look at the script:

local Commons = {"Block","Stick","Bullet"}
local Rares = {"Daggers","Rifle","Hammer"}
local Legendaries = {"Lightning","Fire","Water"}

local number = math.random(1,100)


if number <= 5 then
	local amount = math.random(1,#Legendaries)
	print(Legendaries[amount])
	print("Legendary!")
	
elseif number <= 35 and number >2 then
	local amount = math.random(1,#Rares)
	print(Rares[amount])
	print("Rare!")
	
elseif number <= 100 and number > 35 then
	local amount = math.random(1,#Commons)
	print(Commons[amount])
	print("Common!")
end

Nice work.
That’s basically what I said, but your script will no doubt help someone in the future!