Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

devproduct script not functioning as intended?

Asked by
Donut792 216 Moderation Voter
5 years ago

ok so when someone purchases something it will purchase that 1 thing and if they try to purchase any other or the same devproduct after that nothing happens but it takes the robux this only happened after i added debounce but before that it would let them buy a devproduct it would give them the one they just bought and the previous one included

script:

local Marketplaceservice = game:GetService("MarketplaceService")
local devid = 206197710 --1K
local devid2 = 278740243 --5K
local devid3 = 278740974 --10K
local devid4 = 278742122 --20K
local devid5 = 278742974 --50K
local devid6 = 278743396 --100K
local devid7 = 278760850 --200K
local devid8 = 278761364 --500K
local devid9 = 278761820 --1 Million
local devid10 = 278763424 --Donation
local bought = false
Marketplaceservice.ProcessReceipt = function(receiptinfo)
for i, player in ipairs(game.Players:GetChildren()) do
  if player.UserId == receiptinfo.PlayerId then

    if not bought then
      bought = true
      if receiptinfo.ProductId == devid then
        player.Nut.Coins.Value = player.Nut.Coins.Value + 1000
        bought = false
      end
    end

    if receiptinfo.ProductId == devid2 then
      if not bought then
        bought = true
        player.Nut.Coins.Value = player.Nut.Coins.Value + 5000
        bought = false
      end
    end

    if not bought then
      bought = true
      if receiptinfo.ProductId == devid3 then
        player.Nut.Coins.Value = player.Nut.Coins.Value + 10000
        bought = false
      end
    end

    if not bought then
      bought = true
      if receiptinfo.ProductId == devid4 then
        player.Nut.Coins.Value = player.Nut.Coins.Value + 20000
        bought = false
      end
    end

    if not bought then
      bought = true
      if receiptinfo.ProductId == devid5 then
        player.Nut.Coins.Value = player.Nut.Coins.Value + 50000
        bought = false
      end
    end

    if not bought then
      bought = true
      if receiptinfo.ProductId == devid6 then
        player.Nut.Coins.Value = player.Nut.Coins.Value + 100000
        bought = false
      end
    end

    if not bought then
      bought = true
      if receiptinfo.ProductId == devid7 then
        player.Nut.Coins.Value = player.Nut.Coins.Value + 200000
        bought = false
      end
    end

    if not bought then
      bought = true
      if receiptinfo.ProductId == devid8 then
        player.Nut.Coins.Value = player.Nut.Coins.Value + 500000
        bought = false
      end
    end

    if not bought then
      bought = false
      if receiptinfo.ProductId == devid9 then
        player.Nut.Coins.Value = player.Nut.Coins.Value + 1000000
        bought = false
      end
    end

    if not bought then
      bought = false
      if receiptinfo.ProductId == devid10 then
        player.Nut.Coins.Value = player.Nut.Coins.Value + 4000
        bought = false
      end
    end

  end
end
end
0
Instead of creating a whole new if statement for each product, use elseif. User#19524 175 — 5y
0
alright but now its having the error where if you purchase a devproduct after purchasing another one (either the same or different) it will give you what you bought last time Donut792 216 — 5y

Answer this question