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

Developer Product Not Working?

Asked by 9 years ago

I have been doing some research on developer products and I have edited the sample script they gave on the wiki so that when players bought my developer product, they would receive 500 SpiritCoins (The currency of my game). Though nothing happens when I click the brick the script is in. Is it the location of the script that is messing me up or the script itself? I have a brick with a click detector in it that I want people to buy the developer product from. I went ahead and put the screengui and text button over it as well like the script said as to not change the script a lot. The script is inside the textbutton currently. So the hierarchy for where the script is located is game.Workspace.BuyButton500.ScreenGui.TextButton. Any ideas? Thanks!

--LocalScript in StarterPack
-- setup local variables
local BuyButton500 = game.Workspace.BuyButton500.SurfaceGui.TextButton
local productId = 26121381

-- when player clicks on buy brick prompt him/her to buy a product
BuyButton500.MouseButton1Click:connect(function()
    game:GetService("MarketplaceService"):PromptProductPurchase(game.Players.LocalPlayer, productId)
end)




--Script in BuyButton part
-- setup local variables
local MarketplaceService = game:GetService("MarketplaceService")
local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")
local productId = 26121381

-- define function that will be called when purchase finished
MarketplaceService.ProcessReceipt = function(receiptInfo) 

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


            -- check which product was purchased
            if receiptInfo.ProductId == productId then

                -- handle purchase
                player.leaderstats.SpiritCoins.Value = player.leaderstats.SpiritCoins.Value + 500
            end
        end
    end 

    -- record the transaction in a Data Store
    local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_purchase_" .. receiptInfo.ProductId
    ds:IncrementAsync(playerProductKey, 1)  

    -- tell ROBLOX that we have successfully handled the transaction
    return Enum.ProductPurchaseDecision.PurchaseGranted     
end
0
Why can't all question's be explained in this much detail? Up-voted. ISellCows 2 — 9y
0
Anyone out there know anything different I can try? I still have not figured it out. Malefactus 55 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

Ok the only thing wrong is you need to name the brick (Anything) then say find object then name of brick

0
Can you write the line of code and where it would go in the script? The brick is called, BuyButton500 Malefactus 55 — 9y
Ad

Answer this question