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

Developer Product isn't functioning, why is that?

Asked by 8 years ago

I've been trying to fight this problem for about two days now, I'm trying to use Developer Products to raise a Player's leaderstat, stats. I've looked through Wiki as my first choice, I found a script which was doing just what I needed. The script increased a player's stat called "Money". http://wiki.roblox.com/index.php?title=Developer_product

I've decided to use it in my game, for a ScreenGui shop, well here is the script and it absolutely doesn't function, and gives no output, not prints, nothing - And I am sure my script isn't disabled.

I have this Local Script inside of StarterPack: (This script works correctly)

--LocalScript in StarterPack
-- setup local variables
local buyButton = game.Workspace.BuyButton.SurfaceGui.TextButton
local productId = 29835318

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

And this Server Script inside of ServerScriptService: (This does absolutely nothing)

-- setup local variables
local MarketplaceService = Game:GetService("MarketplaceService")
local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")
local productId = 29835318

game.Players.PlayerAdded:connect(function()
    print("start")
local DeveloperProducts = game:GetService("MarketplaceService"):GetDeveloperProductsAsync():GetCurrentPage()
for _, DevProductContainer in pairs(DeveloperProducts) do
    for Field, Value in pairs(DevProductContainer) do
        print(Field .. ": " .. Value)
    end
    print(" ")
end
print("end")
end)

-- 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. In this case we are healing the player.
                player.leaderstats.Gold.Value = player.leaderstats.Gold.Value + 10
                -- more feedback for the player.
            end
        end
    end 

    -- record the transaction in a Data Store
    local playerProductKey = "p_" .. receiptInfo.PlayerId .. "_p_" .. receiptInfo.PurchaseId
    ds:IncrementAsync(playerProductKey, 1)  

    -- tell ROBLOX that we have successfully handled the transaction
    return Enum.ProductPurchaseDecision.PurchaseGranted     
end

Well, there must be no errors at all, since the script is copied from the ROBLOX Wiki, and there's no output - just does nothing.

0
That's not working either, @ConnorXV excellentAnarchy 50 — 8y

Answer this question