01 | local mps = game:GetService( "MarketplaceService" ) |
02 |
03 | function getPlayerFromId(id) |
04 | for _,v in pairs (game.Players:GetPlayers()) do |
05 | if v.UserId = = id then |
06 | return v |
07 | end |
08 | end |
09 | end |
10 |
11 | mps.ProcessReceipt = function (receiptInfo) |
12 | local productId = receiptInfo.ProductId |
13 | local playerId = receiptInfo.PlayerId |
14 | local player = getPlayerFromId(playerId) |
15 | local productName |
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.
1 | script.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 ) |
5 | end ) |
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.
01 | local mps = game:GetService( "MarketplaceService" ) |
02 |
03 | mps.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 |
14 | end |