How do I change the chance of a person getting a role if they own a gamepass?

I tried making it so if you own a gamepass you are 2 times as likely to the host, but I don’t quite know what to do. Here is the script.

local AudienceTeam = game.Teams.Audience
local HostTeam = game.Teams.Host
local HostChance = 1
game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
        if game.MarketplaceService:PlayerOwnsAsset(player,9416151) then
            HostChance = 2
        end
    end)
end)


game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		local Players = game.Players:GetPlayers()
		local Randomplayer = Players[math.random(1, #Players)]
		while wait(20) do
            if player.Team == AudienceTeam then
                Randomplayer.Team = HostTeam
            end
        end
	end)
end)

Depending on the chance, if you want it to be 2x chance, you can loop through a table of each player in game with the gamepass, and if they own it, add them into the table again.

1 Like