Okay i'll try and guide you, but i'm going to use a Developer Product as that's what im farmiliar with
So inside a button on the players UI, have a button linking to a developer product (Local script)
1 | local MarketplaceService = game:GetService( "MarketplaceService" ) |
2 | local player = game.Players.LocalPlayer |
4 | script.Parent.Activated:Connect( function () |
5 | MarketplaceService:PromptProductPurchase(player, insert developer product id here) |
Then, in a script in server script service
01 | local MarketplaceService = game:GetService( "MarketplaceService" ) |
02 | local DataStoreService = game:GetService( "DataStoreService" ) |
04 | local PreviousPurchases = DataStoreService:GetDataStore( "Receipts" ) |
06 | local developer_product_id = 12342134214 (whatever the product id actually is) |
08 | MarketplaceService.ProcessReceipt = function (receipt) |
11 | local ID = receipt.PlayerId.. "-" ..receipt.PurchaseId |
16 | success = PreviousPurchases:GetAsync(ID) |
21 | return Enum.ProductPurchaseDecision.PurchaseGranted |
24 | local player = game.Players:GetPlayerByUserId(receipt.PlayerId) |
28 | return Enum.ProductPurchaseDecision.NotProcessedYet |
31 | if receipt.ProductId = = developer_product_id |
36 | PreviousPurchases:SetAsync(ID, true ) |
39 | return Enum.ProductPurchaseDecision.PurchaseGranted |
This is a modified script from an AlvinBlox tutorial, so I can't take full credit :P