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