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

How can I convert this script to work for a ScreenGui?

Asked by 9 years ago

I'm trying to learn about MarketPlaceService currently and It's pretty confusing to me.This is a script that UristMcSparx used and I'm just trying to use the same thing, Minus what the Developer product will do. I don't know how to go about making this or if I need another script to make this work for a screen GUI. Here's the script

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

game.Players.PlayerAdded:connect(function()
    print("start")
local DeveloperProducts = game:GetService("MarketplaceService"):GetDeveloperProductsAsync():GetCurrentPage()
for _, DevProductContainer in pairs(DeveloperProducts) do
    for Field, Value in pairs(DevProductContainer) do
        print(Field .. ": " .. Value)
    end
    print(" ")
end
print("end")
end)

-- 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

                -- handle purchase. In this case we are healing the player.
                player.Character.Humanoid.WalkSpeed = player.Character.Humanoid.WalkSpeed + 2

            end
        end
    end 

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

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





I want to Work this inside of a ScreenGui like I said, it's layout it ScreenGui Frame TextButton Script

Would I just add: script.Parent.MouseButton1Click:connect(function() ? But where? I'd like any information I can get to help me learn about this! I also don't know much of anything about DataStore... Side note: How do I view my Data Store to see Purchase history of others?

Answer this question