When I make this it does'nt work am I suppose to make it in the gamepass store? or what? an someone please help? if so join me my username is "dizzycat11"!
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:
------------------------------------------------------------------------------------------------------ --LocalScript in StarterPack -- setup local variables local buyButton = game.Workspace.BuyButton.SurfaceGui.TextButton -- Make a Part and name it BuyButton, Insert a SurfaceGui, and Insert a TextButton into that. local productId = 20518668 -- Make a DeveloperProduct (Not a GamePass) and Change the numbers to the ProductId of your Developer Product -- when player clicks on buy brick prompt him/her to buy a product buyButton.MouseButton1Click:connect(function() game:GetService("MarketplaceService"):PromptProductPurchase(game.Players.LocalPlayer, productId) end) ------------------------------------------------------------------------------------------------------ --Script in BuyButton part -- setup local variables local MarketplaceService = Game:GetService("MarketplaceService") local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory") local productId = 20518668 -- Once again change the numbers to your DeveloperProductId -- define function that will be called when purchase finished 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 -- handle purchase player.Team.LevelNumber.Value = player.Team.LevelNumber.Value + 1 end end end -- record the transaction in a Data Store local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_purchase_" .. receiptInfo.ProductId ds:IncrementAsync(playerProductKey, 1) -- tell ROBLOX that we have successfully handled the transaction return Enum.ProductPurchaseDecision.PurchaseGranted end
If this helped, please hit Accept This Answer underneath my name. :D