How would I make a random room picker, that also has different rarities?
Every room has a Rarity IntValue
I already tried doing this from this post:
local chance = math.random(1,totalWeight) local counter = 0 local randomRoom for _,room in pairs(rooms:GetChildren()) do counter = counter + room.Rarity.Value if chance <= counter then randomRoom = room:Clone() end end
The totalWeight from 10 different rooms is 77
This does not seem to work, as it only selects the room with Rarity 1 every time
How could I fix this?