Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I give the player the item after they purchase my developer product?

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

1 comment

2 answers

✓ Accepted answer

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.

1 comment

0

Thank you, it works perfectly!

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)

2 comments

0

I only know how to do it with tools, so here you go

0

Thats for gamepasses. Does not work with DevProducts.

This discussion is preserved as it was. New answers, comments, and votes are closed.