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

if receiptinfo.ProductId == "random id" then not working but once?

Asked by
Donut792 216 Moderation Voter
5 years ago

so i have my purchase handler script that when a player purchases one of my devproducts they are only able to purchase it once, if they purchase it more than once it will steal their robux and they dont get anything in return

i used to have it without debounce and every if except the first was elseif and that worked fine but every time someone would purchase something it would give them what they paid for plus what they purchase before say they purchase 1000 then purchase 1000 again they get 2000 and if they purchase again they get 3000 and so on and i think nomatter what they purchases it could be 1 million but if they purchased 1000 right before that they would get 2000

so yeah im really struggling here just to get something really simple to work

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

1 answer

Log in to vote
0
Answered by 5 years ago

Why put intire script it would be me doing

local xbox = game:GetService("UserInputService").GamepadEnabled
local UIS = game:GetService("UserInputService")
if xbox then
    script.Parent.Gui.Frame.Position = UDim2.new(0, 0,0.955, 0)
    script.Parent.Gui.Shop.TextButton.Frame.TextButton.Visible = false
    script.Parent.Gui.QuickSell.Visible = true
    script.Parent.Gui.Shop.TextButton.Text = "Shop (A)"
    script.Parent.Gui.Frame.Frame.TextButton.Text = "Click Me (B)"
    script.Parent.Elite.Elite.Position = UDim2.new(0.833, 0,0.908, 0)
end

UIS.InputBegan:Connect(function(key)
    if key.KeyCode == Enum.KeyCode.ButtonB then
        script.Parent.Parent.leaderstats.Clicks.Value = script.Parent.Parent.leaderstats.Clicks.Value+1*script.Parent.Gui.Frame.Multi.Value+script.Parent.Gui.Frame.Petma.Value
        script.Parent.Gui.Frame.TextLabel.Text = "Your Clicks: ".. script.Parent.Parent.leaderstats.Clicks.Value
    end
    if key.KeyCode == Enum.KeyCode.ButtonA then
        local toggled = false
        if toggled == false then
        script.Parent.Gui.Shop.TextButton.Frame.Visible = true
        toggled = true
    else
        script.Parent.Gui.Shop.TextButton.Frame.Visible = false
        toggled = false
    end
    end
    if key.KeyCode == Enum.KeyCode.ButtonY then
        script.Parent.Parent.leaderstats.Clicks.Value = script.Parent.Parent.leaderstats.Clicks.Value*10
        script.Parent.Parent.leaderstats.Cash.Value = script.Parent.Parent.leaderstats.Clicks.Value
        script.Parent.Parent.leaderstats.Clicks.Value = 0
    end
end)

Ad

Answer this question