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

How can I make a developer Product GUI that add's 10 health when purchased?

Asked by
Fendd 5
10 years ago

I have tried and tried and tried but I can't make anything that will work!

Please help!

local MarketplaceService = Game:GetService("MarketplaceService")
local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")
local productId = 19697165 -- Put id here for it


MarketplaceService.ProcessReceipt = function(receiptInfo) 


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



            if receiptInfo.ProductId == productId then
        local a = player.Character.Humanoid.MaxHealth


                player.Character.Humanoid.MaxHealth = a + 10 -- Where the health is added 


                game.Workspace.DisplayScreen.SurfaceGui.TextBox.Text = player.Name .. " has purchased a healing Upgrade." -- Tells the player about the purchase
            end
        end
    end 


    local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_purchase_" .. receiptInfo.PurchaseId
    ds:IncrementAsync(playerProductKey, 1)  


    return Enum.ProductPurchaseDecision.PurchaseGranted     
end

That is the current script. I don't think it works well at all.

2 answers

Log in to vote
-2
Answered by 10 years ago

Search it up on roblox's lua learning site. I'm sure they have connections and events that connect to stuff, as in buying, and receiving.

0
Not a decent answer, but it's an appropriate one. Not everyone gets answered. Wrongmistake 0 — 10y
Ad
Log in to vote
-1
Answered by 10 years ago

Well, first, you need to make sure the player has a character, so,

if player.Character ~= nil then
if player.Character.Humanoid ~= nil then
--blah blah blah
end
end

Answer this question