I need some help wit a random percentage formula that can be influenced

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.

2 Likes

Hey, @Jam_Toad!

This is actually a statistics question.
Check out this website,

https://learn.problemgambling.ca/probability-odds-random-chance

Probably why I cant figure it out haha, I did horrible in stat during high school. Thanks though, Ill read into it!

1 Like

I hated stat as well, I opt’d out of taking it in Junior college and replaced it with a higher level math, just because it was a nuisance.

1 Like

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)]

4 Likes

I like this solution, less math = less chances to mess up… er strike that… you can still mess up

Thanks man, I think I was blowing it out of proportion in my head.

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.

2 Likes

Yea thanks so much man, I had been at this for a long while haha