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

Making this Developer Product give a tool upon purchase

Asked by
Narroby 10
10 years ago

Hello! To check out the new developer product feature, I decided to make this SurfaceGUI in my place where you can buy a product for 10 tickets, and it gives you a tool from Lightning. At first I tried making it using a normal GUI, but I gave up seeing I couldn't figure it out.

I got closer to reaching my goal when using the SurfaceGUI, though. Almost everything is ready; you can click the SurfaceGUI, and it'll show you the message to confirm the purchase. However, I can't make it give you the tool upon purchase, even though I know exactly where I have to edit the script. Code below:

-- setup local variables
local MarketplaceService = Game:GetService("MarketplaceService")
local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")
local productId = "19182249"

-- define function that will be called when purchase finished
MarketplaceService.ProcessReceipt = function(receiptInfo) 

    -- find the player based on the PlayerId in receiptInfo
    for i, player in ipairs(game.Players:GetChildren()) do
        if player.userId == receiptInfo.PlayerId then

            -- check which product was purchased
            if receiptInfo.ProductId == productId then

                -- the part below is the where the tool giving line should be, instead of healing the player
                player.Character.Humanoid.Health = 100
                -- more feedback for the player.
                game.Workspace.DisplayScreen.SurfaceGui.TextBox.Text = player.Name .. " has purchased a healing potion."
            end
        end
    end 

    -- record the transaction in a Data Store
    local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_purchase_" .. receiptInfo.PurchaseId
    ds:IncrementAsync(playerProductKey, 1)  

    -- tell ROBLOX that we have successfully handled the transaction
    return Enum.ProductPurchaseDecision.PurchaseGranted     
end

Right now, what the purchase does is set your health to 100. The tool I want to be given is called GoldenAWP. Could anyone help me? Thanks!

Please keep in mind I can't script at all.

3 answers

Log in to vote
4
Answered by
ImageLabel 1541 Moderation Voter
10 years ago

Try changing the walkspeed code to

game.Lighting["Weapon"]:clone().Parent = player.BackPack
0
Hmmmm, no, it doesn't seem to be working. I can buy the product alright, but the GoldenAWP is not given to the player. Narroby 10 — 10y
Ad
Log in to vote
0
Answered by 10 years ago

If you change it to:

game.Lighting["Weapon"]:clone().Parent = player.BackPack

Then you have to actually put the tool in Lighting.

Log in to vote
0
Answered by 10 years ago

I think you have to put the tool in ReplicatedStorage.

Answer this question