I am trying to make a weapon in which cost robux and there is only a limited quanity of them. Like some games have items which cost robux, that are not gamepasses and they have a timer or a certain quanity before the text says "sold out" Do they do this with dev products? Is there a way to make a dev product only sell a limited amount? Dev product script below
local MarketplaceService = game:GetService("MarketplaceService") local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory") Gear1 = 919223646 local l = game:GetService("Lighting") local G1 = l["Autohyperlaser"] MarketplaceService.ProcessReceipt = function(receiptInfo) local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_product_" .. receiptInfo.ProductId local numberBought = ds:IncrementAsync(playerProductKey, 1) for i,v in pairs (game.Players:GetChildren()) do if v.userId == receiptInfo.PlayerId then if receiptInfo.ProductId == Gear1 then local clone = G1:Clone() clone.Parent = v.Backpack game.Lighting.pass.Value = true end end end return Enum.ProductPurchaseDecision.PurchaseGranted end
Just set make a variable holding the max amount and once they purchase it and there is more than 0, it takes one off from the max amount and so on, until it reaches 0.
local MarketplaceService = game:GetService("MarketplaceService") local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory") Gear1 = 919223646 local l = game:GetService("Lighting") local G1 = l["Autohyperlaser"] local MaxAmount = 30 -- Set this to any amount MarketplaceService.ProcessReceipt = function(receiptInfo) local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_product_" .. receiptInfo.ProductId local numberBought = ds:IncrementAsync(playerProductKey, 1) for i,v in pairs (game.Players:GetChildren()) do if v.userId == receiptInfo.PlayerId then if receiptInfo.ProductId == Gear1 and MaxAmount > 0 then MaxAmount = MaxAmount -1 local clone = G1:Clone() clone.Parent = v.Backpack game.Lighting.pass.Value = true elseif receiptInfo.ProductId == Gear1 and MaxAmount <= 0 then return Enum.ProductPurchaseDecision.NotProcessedYet end end end return Enum.ProductPurchaseDecision.PurchaseGranted end