Answered by
8 years ago Edited 8 years ago
SETUP: First, Make a team for each of your levels and name it Level 1, Level 2, ... and so on. Add an IntValue to every Team and name the IntValue "LevelNumber". Make the IntValue's Value equal the number in the name of the team. Now that we are done with the setup we can get onto the script. :D
SCRIPT:
04 | local buyButton = game.Workspace.BuyButton.SurfaceGui.TextButton |
05 | local productId = 20518668 |
08 | buyButton.MouseButton 1 Click:connect( function () |
09 | game:GetService( "MarketplaceService" ):PromptProductPurchase(game.Players.LocalPlayer, productId) |
14 | local MarketplaceService = Game:GetService( "MarketplaceService" ) |
15 | local ds = game:GetService( "DataStoreService" ):GetDataStore( "PurchaseHistory" ) |
16 | local productId = 20518668 |
19 | MarketplaceService.ProcessReceipt = function (receiptInfo) |
21 | for i, player in ipairs (game.Players:GetChildren()) do |
22 | if player.userId = = receiptInfo.PlayerId then |
24 | if receiptInfo.ProductId = = productId then |
26 | player.Team.LevelNumber.Value = player.Team.LevelNumber.Value + 1 |
31 | local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_purchase_" .. receiptInfo.ProductId |
32 | ds:IncrementAsync(playerProductKey, 1 ) |
34 | return Enum.ProductPurchaseDecision.PurchaseGranted |
If this helped, please hit Accept This Answer underneath my name. :D