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

My scrip isn't working?

Asked by 10 years ago



Ok my script looks like this and it is supposed to add 100 money to the leaderstats after somebody buys the developers product but its not working

local MarketplaceService = game:GetService("MarketplaceService") local MoneyID = 20805766 local PurchaseHistory = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")

MarketplaceService.ProcessReceipt = function(receiptInfo) local playerProductKey = receiptInfo.PlayerId .. ":" .. receiptInfo.PurchaseId if PurchaseHistory:GetAsync(playerProductKey) then return Enum.ProductPurchaseDecision.PurchaseGranted --We already granted it. end -- find the player based on the PlayerId in receiptInfo for i, player in ipairs(game.Players:GetPlayers()) do if player.userId == receiptInfo.PlayerId then -- check which product was purchased (required, otherwise you'll award the wrong items if you're using more than one developer product) if receiptInfo.ProductId == MoneyID then -- handle purchase. In this instance we're giving the player 100 extra gold. player.leaderstats.Money.Value = player.leaderstats.Money.Value + 100 end end end -- record the transaction in a Data Store PurchaseHistory:SetAsync(playerProductKey, true) -- tell ROBLOX that we have successfully handled the transaction (required) return Enum.ProductPurchaseDecision.PurchaseGranted end

1
Please use the lua code block format when posting a script. Necrorave 560 — 10y

1 answer

Log in to vote
0
Answered by 10 years ago

Please edit the text and use the "Code Block" So that people can see and identify the lines of script, For this is what your saying, and it makes no sense.

local MarketplaceService = game:GetService("MarketplaceService") local MoneyID = 20805766 local PurchaseHistory = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")

MarketplaceService.ProcessReceipt = function(receiptInfo) local playerProductKey = receiptInfo.PlayerId .. ":" .. receiptInfo.PurchaseId if PurchaseHistory:GetAsync(playerProductKey) then return Enum.ProductPurchaseDecision.PurchaseGranted --We already granted it. end -- find the player based on the PlayerId in receiptInfo for i, player in ipairs(game.Players:GetPlayers()) do if player.userId == receiptInfo.PlayerId then -- check which product was purchased (required, otherwise you'll award the wrong items if you're using more than one developer product) if receiptInfo.ProductId == MoneyID then -- handle purchase. In this instance we're giving the player 100 extra gold. player.leaderstats.Money.Value = player.leaderstats.Money.Value + 100 end end end -- record the transaction in a Data Store PurchaseHistory:SetAsync(playerProductKey, true) -- tell ROBLOX that we have successfully handled the transaction (required) return Enum.ProductPurchaseDecision.PurchaseGranted end
Ad

Answer this question