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

My Devproducts Script wont work?

Asked by 9 years ago

Please provide more explanation in your question. If you explain exactly what you are trying to accomplish, it will be much easier to answer your question correctly.

--Hello, I do not know what to do. --It just doesnt work.

--Its in a localscript in starterGui

local MarketplaceService = game:GetService("MarketplaceService")
local PowerManId = 23355962
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 == PowerManId then
                -- handle purchase. In this case we are healing the player.
                player.Character.Humanoid.Health = 200
                player.Character.Humanoid.WalkSpeed = 32
                player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + 3200
            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 answer

Log in to vote
0
Answered by 9 years ago

You need it in a Server Script

0
I deleted the localscript, and put the script in ServerScriptService, and still not working.. wow iiZexyii 0 — 9y
Ad

Answer this question