How could I pick a player from a percentage (with dev product)

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to be able to pick someone to be it/siren head in my game but to increase your chances you can buy a developer product.

  2. What is the issue? Include screenshots / videos if possible!
    I can’t figure out how to do it.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have looked for solutions on the developer hub/forum, although they were either not working or not good in my situation.
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category. (sorry if this is a big ask)

Oh this is a simply one. Simply use a non pure function such as the random method and decrease the foci. Example -

local function codeToProcessIfPlayerIsChossen()
  return end
local hasGamePass = false
-- gamepass event
hasGamePass = true
-- siren head event
if hasGamePass then
  if math.random(0, 10) == 0 then
  elseif not hasGamePass then
   if math.random(0, 100) == 0 then
1 Like

If you’re doing it based on percentage then this is how you should think about it.

Let’s say you have 5 players and each player has a value of 5 for your percentage ‘wheel.’ In this scenario each player would have a 20% chance of being picked because there is a total of 25 in the value. Now let’s say one player decides to purchase a dev product that grants the 10 more points, now that player has a 42% chance of winning while everyone else has a 14% chance of winning because there is now a total of 35 points.

Now how do you tell your script to do this?
Well first you gather your particpants by using a table, use table.insert for the players.
Then you get a total of the points which you can get from each player’s leaderboard stats of the points they have and add them together.
Then to generate the random number you just use math.random(0, TotalNumber)
And once you have your randomly generated number, you go through each participant by setting an inital check value.
The inital check value will be 0 and you check if the generated number is greater than the inital check value and less than or equal to the inital check value plus the participant’s value. If they meet that statement, you have your winner, otherwise you continue down the list of partipants until you have your lucky winner.

Of course if you’re going to make it where players can pay real money to increase their chances, you should make the values of each player save and also avoid implementing real gambling into your game.