I'm making a tycoon and I want to make dev products to help with speed, cash, and health. Here's what I did.
game.StarterGui.ResetPlayerGuiOnSpawn = false old_fog = game.Lighting.FogStart local MarketplaceService = game:GetService("MarketplaceService")
function getPlayerFromId(id) for i,v in pairs(game.Players:GetChildren()) do if v.userId == id then return v end end return nil end
MarketplaceService.ProcessReceipt = function(receiptInfo) local productId = receiptInfo.ProductId local playerId = receiptInfo.PlayerId local player = getPlayerFromId(playerId) local productName
-- Down below is an example of a Cash boost ------------------------------------------------------------------- if productId == 310891759 then local cashmoney = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name) if cashmoney then cashmoney.Value = cashmoney.Value + 50000 end elseif productId == 310891034 then local cashmoney = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name) if cashmoney then cashmoney.Value = cashmoney.Value + 100000 end ------------------------------------------------------------------- -- Down below is an example of a Health boost ------------------------------------------------------------------- elseif productId == 310891759 then local char = player.Character char.Humanoid.MaxHealth = char.Humanoid.MaxHealth + 20 wait() char.Humanoid.Health = char.Humanoid.MaxHealth ------------------------------------------------------------------- -- Down below is an example of a WalkSpeed boost ------------------------------------------------------------------- elseif productId == 310892411 then local char = player.Character if char then local human = char:FindFirstChild("Humanoid") if human then human.WalkSpeed = human.WalkSpeed + 5 end end elseif productId == 310892160 then local char = player.Character if char then local human = char:FindFirstChild("Humanoid") if human then human.WalkSpeed = human.WalkSpeed + 10 end end ------------------------------------------------------------------- -- Down below is an example of a gear giver ------------------------------------------------------------------- elseif productId == 310892411 then game.ServerStorage.GodlySword:Clone().Parent=player.Backpack ------------------------------------------------------------------- end return Enum.ProductPurchaseDecision.PurchaseGranted
end
But when I do a test purchase, it doesn't work. Help?
Closed as Not Constructive by User#19524 and amanda
This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.
Why was this question closed?