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

Problem with a Dev Product giving a item from a gui?

Asked by 1 year ago
Edited 1 year ago

The dev product shows up when I click the TextButton but when I buy it I dont get the item. I have a script in ServerScriptService here it is.

local marketplaceService = game:GetService("MarketplaceService")
local players = game:GetService("Players")
local productId = 1338743761
local Tool = game.ReplicatedStorage.CuddlyCat
local Players = game:GetService("Players")

marketplaceService.ProcessReceipt = function(receipt)
    local player = players:GetPlayerByUserId(receipt.PlayerId)
    if not player then
        return Enum.ProductPurchaseDecision.NotProcessedYet
    end
    if receipt.ProductId == productId then
        Tool:Clone().Parent = Players.LocalPlayer.Backpack
    end
    return Enum.ProductPurchaseDecision.PurchaseGranted
end

and the localscript in the text button. Here it is.

local marketplaceService = game:GetService("MarketplaceService")
local productId = 1338743761

script.Parent.MouseButton1Click:Connect(function()
    marketplaceService:PromptProductPurchase(game.Players.LocalPlayer, productId)
end)
0
In the first script, change line 13 to `Tool:Clone().Parent = player.Backpack` because `Players.LocalPlayer` doesn't work on normal scripts. T3_MasterGamer 2189 — 1y
0
Thank you! :D tonomeow 5 — 1y

1 answer

Log in to vote
1
Answered by 1 year ago

All I had to do was replace line 13 in the first script with

Tool:Clone().Parent = player.Backpack

And it works now!

-credit to T3_MasterGamer for the answer.

Ad

Answer this question