Help with making gamepasses stack

So… I have a gamepass handler that handles every gamepass.

local marketPlaceService = game:GetService("MarketplaceService")

game.Players.PlayerAdded:Connect(function(player)
	
	local folder = Instance.new("Folder",player)
	folder.Name = "Gamepasses"
	
	local cashMultiplier = Instance.new("NumberValue",folder)
	cashMultiplier.Name = "Cash"
	if marketPlaceService:UserOwnsGamePassAsync(player.UserId, 8349933) then
		cashMultiplier.Value = cashMultiplier.Value + 2
	end
	
	local crystalsMultiplier = Instance.new("NumberValue",folder)
	crystalsMultiplier.Name = "Crystals"
	if marketPlaceService:UserOwnsGamePassAsync(player.UserId, 8583196) then
		crystalsMultiplier.Value = crystalsMultiplier.Value + 2
	end
	
	local cocoaMultiplier = Instance.new("NumberValue",folder)
	cocoaMultiplier.Name = "Cocoa"
	if marketPlaceService:UserOwnsGamePassAsync(player.UserId, 8628892) then
		cocoaMultiplier.Value = cocoaMultiplier.Value + 2
	end
	
	local xpMultiplier = Instance.new("NumberValue",folder)
	xpMultiplier.Name = "XP"
	if marketPlaceService:UserOwnsGamePassAsync(player.UserId, 8583218) then
		xpMultiplier.Value = xpMultiplier.Value + 2
	end
	
	if marketPlaceService:UserOwnsGamePassAsync(player.UserId, 8628910) then
		xpMultiplier.Value = xpMultiplier.Value + 2
		cashMultiplier.Value = cashMultiplier.Value + 2
		cocoaMultiplier.Value = cocoaMultiplier.Value + 2
		crystalsMultiplier.Value = crystalsMultiplier.Value + 2
	end
	
	local autoCollectCash = Instance.new("BoolValue",folder)
	autoCollectCash.Name = "Auto Collect Cash"
	if marketPlaceService:UserOwnsGamePassAsync(player.UserId, 8583215) then
		autoCollectCash.Value = true
	end
end)

So if the player owns a gamepass, the value goes up by 2. I just realized that if the player doesn’t own the gamepass the values default to 0.

How would I make the values stack? For example: 2x goes to 4x, 4x to 6x, etc. There is a stat bundle and if you own both gamepasses, 2x Cash would go to 4x Cash.

1 Like

Why do you not have a set value and only assign values if they own a gamepass? That’s why it’s 0.

1 Like

Exactly. But if I do this:

local folder = Instance.new("Folder",player)
	folder.Name = "Gamepasses"
	
	local cashMultiplier = Instance.new("NumberValue",folder)
	cashMultiplier.Name = "Cash"
	cashMultiplier.Value = 1
	if marketPlaceService:UserOwnsGamePassAsync(player.UserId, 8349933) then
		cashMultiplier.Value = cashMultiplier.Value + 2
	end

That would set it to 3, not 2. So, I need to find a way to do this.

I found a solution, probably should’ve thought before making this topic.