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

Developer Product Value?

Asked by 9 years ago

I am trying to work on this in my game, and when I buy the product it does not give me my credits.

local service = game:GetService("MarketplaceService")
local player = game.Players.LocalPlayer

local buyButton = script.Parent
local productId = 23429504

buyButton.MouseButton1Click:connect(function()
game:GetService("MarketplaceService"):PromptProductPurchase(game.Players.LocalPlayer, productId)
if service:PlayerOwnsAsset(game.Players.LocalPlayer, productId) then
game.Players.LocalPlayer = game.Players.LocalPlayer + 10
end
end)

0
Code block please EzraNehemiah_TF2 3552 — 9y
0
fixed UnleashedGamers 257 — 9y
0
I believe you shouldn't be activating what will happen with the Product in the Client script. Do it within your Server Sided. Look at Uristmcsparx example for ROBLOX Wiki alphawolvess 1784 — 9y
0
@alpha, he's not defining the ProcessReceipt in his localscript, so it's fine. The ProcessReceipt is what controls what happens when someone purchases a Developer Product. If he were then that would be a problem, but he's not. Goulstem 8144 — 9y

2 answers

Log in to vote
0
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
9 years ago

In order for you to obtain anything from buying a Developer Product, you need to define the ProcessReceipt of MarketPlaceService.

Read more here

NOTE: The ProcessReceipt can only be defined in a server script(regular script) - attempting to define it in a localscript will cause it to not work.

Ad
Log in to vote
-1
Answered by 9 years ago

Your script would error, to fix this figure out where the cash is. This is the server's side of the script.

function CompletePurchase()
    --This will error below, may need to know what you really want it to do.
    game.Players.LocalPlayer = game.Players.LocalPlayer + 10
end

local MarketplaceService = Game:GetService("MarketplaceService")
local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")
local productId = 23429504


MarketplaceService.ProcessReceipt = function(receiptInfo) 


    for i, player in ipairs(game.Players:GetChildren()) do
        if player.userId == receiptInfo.PlayerId then


            if receiptInfo.ProductId == productId then

                CompletePurchase()
            end
        end
    end 

    local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_purchase_" .. receiptInfo.PurchaseId
    ds:IncrementAsync(playerProductKey, 1)  

    return Enum.ProductPurchaseDecision.PurchaseGranted     
end

Here's the player's side:

local buy = script.Parent
local productId = 23429504

buy.MouseButton1Click:connect(function()
    game:GetService("MarketplaceService"):PromptProductPurchase(game.Players.LocalPlayer, productId)
end)

I will say that I don't know where the BuyButton is, so you'll have to change buy to where its at. The server's side goes in the model. The player's side goes in a local script in the StarterPack and possibly in the model in which that may make it even easier. Tell me if there's any errors.

0
Why are you adding 10 to localplayer? DigitalVeer 1473 — 9y
0
I followed what the original script has it do. ChefBuckeye 0 — 9y
0
Line 10; The original script. ChefBuckeye 0 — 9y
0
I know it will error, if I can get a hold with him then I'll tell him that it will error. ChefBuckeye 0 — 9y

Answer this question