Adding on to @Kacper’s answer, see: https://medium.com/@peterkellyonline/weighted-random-selection-3ff222917eb6 to visualize how this works. You could do something along the lines of the snippet below to implement an “increase” in weights based on various factors (i.e gamepass ownership, play time);
local MarketplaceService = game:GetService("MarketplaceService");
local MultProduct = 12345;
local Participants -- define
local function getNextMurderer()
local selected = nil;
local TotalWeight = 0;
local Weights = {};
--Participants: game.Players:GetPlayers or players joining next round
for index, player in pairs(Participants) do
-- Give every participant a starter weight of 10 pts
Weights[index] = 10;
if MarketplaceService:UserOwnsGamePassAsync(player.UserId, MultProduct) then
--multiplier of 10 for every player that owns the relevant gamepass
Weights[index] = Weights[index] * 10
end
TotalWeight = TotalWeight + Weights[index]
end
--select a random ticket from the pool (random number ranging from 1 to sum of weights)
local ticket = Random.new():NextInteger(1, TotalWeight);
for index = 1, TotalWeight do
-- subtract from the sum of weights until we reach 0
-- the higher the weight the higher the chances of reaching 0
ticket = ticket - Weights[index]
if ticket <= 0 then
--select the winner
selected = Participants[index]
break
end
end
return selected;
end
print(getNextMurderer())