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

"Feature is turned off" when using DevProducts?

Asked by 9 years ago

I've got a DevProduct script, and so far I assume it works fine, but when I activate it, it gives me "Feature is turned off" in the Server Console. How can I fix this?

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

script.Parent.MouseButton1Click:connect(function()
local DeveloperProducts = game:GetService("MarketplaceService"):GetDeveloperProductsAsync():GetCurrentPage()
for _, DevProductContainer in pairs(DeveloperProducts) do
    for Field, Value in pairs(DevProductContainer) do
        print(Field .. ": " .. Value)
    end
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 adding gems
                player.leaderstats.Gems.Value = player.leaderstats.Gems.Value + Gems

            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

If you can make this more efficient, or shorter, please feel free to do so.

1 answer

Log in to vote
0
Answered by 9 years ago

The script handling the purchase must be in workspace, where as the script handling what you see when you click a button is a local script in the button. You can read more about it here: http://wiki.roblox.com/index.php?title=Developer_product If you have any more questions, just say.

0
I've edited my answer. SlickPwner 534 — 9y
0
thank you. rollercoaster57 65 — 9y
Ad

Answer this question