Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why is my script not killing the person who purchases it?

local productId = 46716504 
local player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:connect(function(hit)
	game:GetService("MarketplaceService"):PromptProductPurchase(player, productId)
	hit.Parent.Humanoid.Health=-99999999
end)

1 answer

✓ Accepted answer

###This is because MouseButton1Click passes no parameters, so hit is nil. Since the player is already defined, use that instead.

local productId = 46716504 
local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
    game:GetService("MarketplaceService"):PromptProductPurchase(
        player, 
        productId
)
    player.Character.Humanoid.Health= 0 -- no need to set the health to something unrealistic, 0 is enough 
end)

###On a side note, :connect() is deprecated, use :Connect() instead.

This discussion is preserved as it was. New answers, comments, and votes are closed.