I have multiple dev product scripts that give you something different depending on what product you buy. I have a shop gui where you can select which product you want to buy. Then I have a script for each product in the ServerScriptService that detects when a product is bought and give the player what they bought. My problem is that every time I go into the game only one product works and its random every time. Theres also no errors in the output. I'm not sure what's happening, please help! Heres the script:
local mkps = game:GetService("MarketplaceService") local ProductId = 1291342629 local character = game.Players.LocalPlayer local function processReceipt(receiptInfo) local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId) local gui = player.PlayerGui.Stats.Timer -- timer local none = player.PlayerGui.Stats.None -- "none" text for when the timer is done local NoBuy = player.PlayerGui.Shop.WalkingProducts.NoBuy local NoBuyText = player.PlayerGui.Shop.WalkingProducts.NoBuyStackText if not player then return Enum.ProductPurchaseDecision.NotProcessedYet elseif player then if receiptInfo.ProductId == ProductId then none.Visible = false gui.Visible = true NoBuy.Visible = true NoBuyText.Visible = true print("player bought 30 min of time") player.Character.Humanoid.WalkSpeed = 16 -- changes player walk speed from 0 to 16 for i = 1800, 1, -1 do -- sets 30 second timer gui.Text = tostring(i) wait(1) end gui.Visible = false none.Visible = true NoBuy.Visible = false NoBuyText.Visible = false player.Character.Humanoid.WalkSpeed = 0 -- back to 0 walkspeed when 30 seconds are done end return Enum.ProductPurchaseDecision.PurchaseGranted end end mkps.ProcessReceipt = processReceipt
Its the same script for each dev product it just has a different productID and a different reward
Just figured it out. In order to make it work, I just added a bunch of if statements inside of one script.