Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago

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

2 answers

Log in to vote
0
Answered by 6 years ago

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.

0
Thank you, it works perfectly! supertroopa3 6 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

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)

0
I only know how to do it with tools, so here you go Digital_Madness 0 — 6y
0
Thats for gamepasses. Does not work with DevProducts. MrCatDoggo 213 — 6y

Answer this question