This script doesnt work why?
It was supposed to give my players 10k Cash ingame when buyed.
If anyone has the [Speed,Cash Giver, JetPack] And so on developer script please send them! :)
My leaderboard script is called " LinkedLeaderboard
"
local buyButton = script.Parent local productId = 22771222 --change to dev product id local mps = game:GetService"MarketplaceService" function getPlayerById(id) for i,v in pairs(game.Players:GetPlayers()) do if v.userId == id then return v end end end buyButton.MouseButton1Click:connect(function() mps:PromptProductPurchase(game.Players.LocalPlayer, productId) end) mps.ProcessReceipt = function(info) local plr = getPlayerById(info.PlayerId) if plr and plr:FindFirstChild"leaderstats" and plr.leaderstats:FindFirstChild"LinkedLeaderboard" then player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + 10000 end end local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_purchase_" .. receiptInfo.PurchaseId ds:IncrementAsync(playerProductKey, 1) return Enum.ProductPurchaseDecision.PurchaseGranted
Your problem is that you ended the ProcessReceipt function before updating DataStores, and returning PurchaseGranted.
Also, i'm assuming your third condition in the if statement on line 19 is messing other things up. Remove it, i'm almost positive it's unnecessary.
Lastly, this should only be used in a Server Script, so in your PromptPurchase method you're going to have to find another way to access the player.
Line 19, 3rd Condition;
plr.leaderstats:FindFirstChild"LinkedLeaderboard"
local buyButton = script.Parent local productId = 22771222 --change to dev product id local mps = game:GetService"MarketplaceService" function getPlayerById(id) for i,v in pairs(game.Players:GetPlayers()) do if v.userId == id then return v end end end buyButton.MouseButton1Click:connect(function() mps:PromptProductPurchase() --Access the player end) mps.ProcessReceipt = function(info) local plr = getPlayerById(info.PlayerId) if plr and plr:FindFirstChild("leaderstats") then local stat = plr.leaderstats.Cash stat.Value = stat.Value + 10000 end local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_purchase_" .. receiptInfo.PurchaseId ds:IncrementAsync(playerProductKey, 1) return Enum.ProductPurchaseDecision.PurchaseGranted end
Closed as Not Constructive by ConnorVIII and evaera
This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.
Why was this question closed?