How to make a "system" of boxes that give random Towers depending on their rarity? (read description for more detailed information)

Hello, I want to know how to make a specific “box system” for a Tower Defense game, the system where you open boxes and get random towers with probabilities and percentages depending on the rarity of the Tower (Common, Rare, Epic, Legendary , Mythical, Etc.) like Toilet Tower Defense or practically the majority of Tower Defense games that exist, it is a widely used system, and it is much better than buying the Towers directly, in addition you can also “store and accumulate” Towers to be able to Trade them with other users the problem is that there is no information ANYWHERE, I searched on Youtube, in Roblox DevForum and in Discord groups, no one makes a tutorial on this topic, (and I must clarify, I used the Tower Defense Gnomecode tutorial, I’m basing it on the Gnomecode Tower Defense of course, I changed and revamped it for my account to make it unique), but the system of buying Towers individually with different amounts of money is very "outdated, does anyone know how to make a crate system that give random Towers with different percentages depending on their rarity (common, rare, epic, legendary, mythical, etc.)?

To clarify, I know there is a warning not to ask for help for complete systems, so I am asking for advice and what codes I can do, maybe something related to random math?, but i dont know much about this, i hope you can help me, thanks

old and outdated system of buying Towers individually

New amazing box/crate system

2 Likes

hm, my advice would be to generate a random number and see which probability range it falls into, so like if it generates a number higher < 0.5, then it would be a common tower, if generated a number < 0.8 then a rare tower, something like that.

however, creating the box system, well I don’t think I could just create it for you right here right now, I would require a setup of the game, where the towers are, and basically yeah.

happy holidays

Look into weighted chance algorithms

Give each ui element that should have a rarity an IntValue and set the LayoutOrder of the UI Element to the rarity intvalue. Then set the UIListLayout.SortOrder be equal to Enum.SortOrder.LayoutOrder