I am working on a game where you by default have a (100 / NumberOfPlayersIngame) chance to get the special character. (Very similar to Murder Mystery)
The point where I am having trouble is you can purchase a thing called “Double Chance”.
This means that if you have double chance and there are 5 people in the game then the formula would be (100 / NumberOfPlayersIngame) * 2 and then the difference would be split among the others.
What if 2 people bought the double gamepass, or 3 people. This is where I get extremely lost and I need your help.
If 2 people bought it then what would the formula be? What if 3 people bought the double gamepass?
I have been trying to think of a formula that would work for any number of players that bought the gamepass, but I cant seem to figure it out.
Thank you for your time and hopefully someone can help me out. I have been working on this for a couple hours and cant figure it out.
A way to do this without a lot of math could be to create a table of players as a ‘drawing pool’, then for each player that has the double chance add their name in a second time.
local list = {}
for _, player in ipairs(game:GetService("Players"):GetPlayers()) do
table.insert(list, player)
if (purchasedDoubleChance(player)) then
table.insert(list, player) -- Add their name twice
end
end
local randomPlayer = list[math.random(#list)]
Yeah, I don’t know much about statistics either so if other people have double chance as well then it wouldn’t literally double your probability of being chosen. My answer is more like pulling names out of a hat where some people can have their names put in twice.