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

Dev Product Script not Working?[UNSOLVED]

Asked by 10 years ago

I got everything sorted out except from giving the Player the gear when he purchase the Dev Product. So Basically the script is suppose to give player the gear if they buy the Developer Product.

local plr = script.Parent.Parent.Parent.Parent.Parent
local link = game:GetService("MarketplaceService")
deb = 0


script.Parent.MouseButton1Click:connect(function()
local marketId = 21055716 --Here Developer Product ID
link:PromptProductPurchase(plr,marketId)
link.ProcessReceipt = function(receiptInfo)
if Enum.ProductPurchaseDecision.PurchaseGranted and receiptInfo.PlayerId == plr.userId then
if deb == 0 then
deb = 1
local c = game.Lighting.DualVenomshank:Clone()--Here where I'm clonning which is in workspace
    c.Parent = game.Lighting--This put the clone into the Lighting

local give = game.Lighting:FindFirstChild("DualVenomshank")--Here where the script search for "DaulVenomshank"
    give.Parent = game.StarterPack--Here it where it post to give the Player Who bought the "Dev Product" the gear 
wait(1)
deb = 0
end
end
end
end)

1 answer

Log in to vote
0
Answered by 9 years ago

The problem here is that you are putting the object into the game.StarterPack, which means every player will receive it whenever they respawn. To give it to the player, you must put it in plr.Backpack.

Also, you don't seem to fully understand the .ProcessReceipt concept. When you write that function, you are overwriting the existing one. This means that you will break all the other player's scripts. So if two players buy at the same time, your script will fail and one player will not receive the item. It is a much better idea to move that function to game.ServerScriptService and re-write it to do so.

You can learn more about developer products here.

I hope this helped!

Ad

Answer this question