I have created a part to use in my game, and inserted a Script in said Part along with a ClickDetector. I used this code so when I click the part It prompts me to purchase my Lemonade Item:
local MarketplaceService = game:GetService("MarketplaceService") local Part = script.Parent local ClickDetector = Part:WaitForChild("ClickDetector") local ProductId = 104605498 ClickDetector.MouseClick:Connect(function(Player) MarketplaceService:PromptProductPurchase(Player, ProductId) end)
Now I just need to know how to actually give the player the lemonade after they complete the Transaction. Thanks for the help :D
For this you need a DevProductHandler.
A good person so check out is Zednov. He made a DevProduct kit.
Or use this script below.
local Marketplace = game:GetService("MarketplaceService") Marketplace.ProcessReceipt = function(RInfo) local PlayerId = RInfo.PlayerId local ProductId = RInfo.ProductId local Player = game.Players:GetPlayerByUserId(PlayerId) if ProductId == 0 then --Insert Code Here-- end return Enum.ProductPurchaseDecision.PurchaseGranted end
for the "--Insert Code Here--", as your going for a tool clone, You would use a basic clone function.
local tool = game.ReplicatedStorage["Tool Name"] local target = Player.Backpack local Clone = tool:Clone() Clone.Parent = target
And as for the id just replace the 0 in "if ProductId == 0 then" with your DevProdcut id.
local passid =
local tools = {""}
local GamePassService = Game:GetService('GamePassService')
game.Players.PlayerAdded:connect(function(player)
repeat wait(0.1) until player.Backpack
repeat wait(0.1) until player.StarterGear
if GamePassService:PlayerHasPass(player, passid) then
for i = 1,#tools do
game.Lighting:FindFirstChild(tools[i]):Clone().Parent = player.Backpack
game.Lighting:FindFirstChild(tools[i]):Clone().Parent = player.StarterGear
end
end
end)