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

Developer product textbutton that kills you when bought?

Asked by
DanzLua 2879 Moderation Voter Community Moderator
9 years ago

Hello, i'm trying to kill the player who buys a developer product. the script is not working below is the error in the output when i buy it in the game using F9, and the script i'm using.

Players.smalldaniel.PlayerGui.ScreenGui.TextButtontt.Script:15: attempt to index global 'MarketplaceService'(a nil value)

productId = 21073044 

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 playerProductKey = "player_" .. receiptInfo.PlayerId .. "_purchase_" .. receiptInfo.PurchaseId
            ds:IncrementAsync(playerProductKey, 1)  
        return Enum.ProductPurchaseDecision.PurchaseGranted  
               end Workspace.player.Humanoid.Health = 0
            end
        end
end


Thank you

0
I think you have an 'end' too much. Atleast, that's what I see in the script above. I'm not sure what you have there. Do you have a local MarketplaceService declared? damagex443 325 — 9y

1 answer

Log in to vote
0
Answered by
iaz3 190
9 years ago

You have to use GetService to get the service.

Read http://wiki.roblox.com/index.php?title=Developer_product

local MarketplaceService = Game:GetService("MarketplaceService") --Notice how it is defined.

MarketplaceService.ProcessReceipt = function(receiptInfo)
    game.Workspace.DisplayScreen.SurfaceGui.TextBox.Text = receiptInfo.PlayerId .. " just bought " .. receiptInfo.ProductId
    -- ...
    -- use DataStore to record purchase
    -- ...  
    return Enum.ProductPurchaseDecision.PurchaseGranted     
end
Ad

Answer this question