How To Randomly Choose a Player W/ Increased Chance For Gamepass Holders?

I’m trying to make a political simulation game. I understand how to randomly select/call a player out of all online players. However, I want to increase the chances of a player being chosen whether from a gamepass or whatnot (possibly being in a group or on an admin list also).

Is it possible to somehow combine the total player list with a special list to double the chances for certain players? If so how’d I go about doing that?

Here’s an older post I’ve been using to randomly select a player:

3 Likes

The best way to do this that I can think of off the top of my head would just be storing all the players you have to pick from within a table and adding multiple entries if they own a gamepads that gives them a higher chance. I don’t believe it’s possible to weight the results when getting it from Players:GetPlayers().

1 Like

Do you have any posts you recommend on creating tables and how I’d go about adding active players to it?

Something like this should help

local function SelectAUser(Querylist)
    local SelectionArray = {};
        for _,g in pairs(Querylist)do
            table.insert(SelectionArray, g);
                if(PlayerMeetsCondition)then
                    table.insert(SelectionArray,g);
                end;
        end;
return SelectionArray[math.random(1,#SelectionArray)];
end;

--//
local User = SelectAUser(game:GetService("Players"):GetPlayers());
2 Likes

I’ll write some pseudocode.

local selectablePlayers = {}

PlayerAdded(plr)
    if userOwnsPass() then
          table.insert(selectablePlayers, plr)
    end

    table.insert(selectablePlayers,plr)
end

Then just pick your player out of that table using some of the code from above.

1 Like