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

Using DevProducts on a TextButton?

Asked by 10 years ago

I used a template for this but instead of a surface gui I need it to work on a TextButton. No Output besides "Place has to be opened with edit button to access DataStores"

local MarketplaceService = Game:GetService("MarketplaceService")
local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")
local productId = 19181612
local cookiesincrease = 1000

-- define function that will be called when purchase finished
--script.Parent.MouseButton1Click:connect(function(click)
    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

                    game.Workspace.cookies = game.Workspace.cookies + cookiesincrease
                end
            end
        end 

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


        return Enum.ProductPurchaseDecision.PurchaseGranted     
    end
--end)
0
What this script is for is to process when someone buys that Dev Product. lomo0987 250 — 10y
0
I'm trying to get it to pop up saying "Would you like to purchase this product" or whatever it says. :P YellowoTide 1992 — 10y

2 answers

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Put in local in text-button

Here:

lMPS = game:GetService("MarketplaceService")
id = 653936051 
local player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
    MPS:PromptProductPurchase(player, id)
end)

I have used this script in another answer before this is risky...

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

You need to go play your game like you play any other game on roblox. When you are in the game, just press F9 and look at the Server Console and Local Console for problems.

0
No output in dev console YellowoTide 1992 — 10y

Answer this question