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

This devproduct script exponentially dupes my tools, anyway to fix it?

Asked by
BashGuy10 384 Moderation Voter
4 years ago
Edited 4 years ago
01local mps = game:GetService("MarketplaceService")
02 
03function getPlayerFromId(id)
04    for _,v in pairs(game.Players:GetPlayers()) do
05        if v.UserId == id then
06            return v
07        end
08    end
09end
10 
11mps.ProcessReceipt = function(receiptInfo)
12    local productId = receiptInfo.ProductId
13    local playerId = receiptInfo.PlayerId
14    local player = getPlayerFromId(playerId)
15    local productName
View all 22 lines...

I've never been a good person with devproducts, but now if i give this tool, it exponentially multiplys.

No idea how to fix it TBH.

1script.Parent.ClickDetector.MouseClick:Connect(function(clicker)
2    local mps = game:GetService("MarketplaceService")
3    local player = game.Players:FindFirstChild(clicker.Name)
4    mps:PromptProductPurchase(player, 1004818393)
5end)
0
btw it keeps going like n * n + n, by the third buy you have six tools. BashGuy10 384 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Hi there. I don't know much about Dev Products, but on line 20, you wrote chosenGun = player.Backpack. This wouldn't work as you would be setting the choesn gun to player.Backpack. Instead, use .Parent.. Also, there's no need to use an extra function for getting the player from its user ID. You can use the built-in GetPlayerByUserId function of Players.

If this doesn't work, give us the script that fires the receipt function. It might be something simple, like adding a debounce.

01local mps = game:GetService("MarketplaceService")
02 
03mps.ProcessReceipt = function(receiptInfo)
04    local productId = receiptInfo.ProductId
05    local playerId = receiptInfo.PlayerId
06    local player = game.Players:GetPlayerByUserId(playerId)
07    local productName
08 
09    if productId == 1004818393 then
10        local guns = game.ServerStorage.RandomWeapons:GetChildren()
11        local chosenGun = guns[math.random(1, #guns)]:Clone()
12        chosenGun.Parent = player.Backpack
13    end
14end
0
it keep duplicating tools, gonna post the function fire in the question BashGuy10 384 — 4y
Ad

Answer this question