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

Developer product textbutton that kills you when bought?

Asked by
DanzLua 2879 Moderation Voter Community Moderator
10 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:37: attempt to index global 'receiptinfo'(a nil value)

the script below has been edit Again

productId = 21073044 

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

1 answer

Log in to vote
1
Answered by
bbissell 346 Moderation Voter
10 years ago

When you close the ProcessReceipt function on line 20, the variable "receiptInfo" goes nil. This means, when you call the "recieptinfo" variable after you close the function, the script will error as it did when you tested it. The following code should be in that function.

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

return Enum.ProductPurchaseDecision.PurchaseGranted   

Like this...

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  
                Workspace.player.Humanoid.Health = 0
            end
        end
end
end
0
Hey bbissell in the script that u gave me when i run it, it doesn't work, it also gives me the same error, i edited the script i posted to show u what i am now using. DanzLua 2879 — 10y
0
No no no... You pasted it in the wrong spot. Please post the origional code again.. bbissell 346 — 10y
0
Ok so there was a little little error in the script that was 10 with a end i put there but it didn't work, there is a new error now here it is Players.smalldaniel.PlayerGui.ScreenGui.TextButtontt.Script:15: attempt to index global 'MarketplaceService'(a nil value) . i edit the post with your script i fixed a little DanzLua 2879 — 10y
0
Bump DanzLua 2879 — 10y
Ad

Answer this question