Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

My Devproducts Script wont work?

--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

✓ Accepted answer

You need it in a Server Script

1 comment

0

I deleted the localscript, and put the script in ServerScriptService, and still not working.. wow

This discussion is preserved as it was. New answers, comments, and votes are closed.