The script is supposed to kill you when you purchase it. The leaderstats part works and so does the prompt to purchase. But it doesn't kill you.
Script:
01 | local MarketplaceService = game:GetService( "MarketplaceService" ) |
02 | local RemoteEvent = game.ReplicatedStorage.PromptSkipStagePurchase |
03 | local productId = 1164319291 |
04 |
05 | -- Prompt purchase |
06 | RemoteEvent.OnServerEvent:Connect( function (player) |
07 | MarketplaceService:PromptProductPurchase(player, productId) |
08 | end ) |
09 |
10 | -- Skip function |
11 | MarketplaceService.ProcessReceipt = function (receiptInfo) |
12 | if receiptInfo.ProductId = = productId then |
13 |
14 | local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId) |
15 |
16 | player.leaderstats.Stage.Value = player.leaderstats.Stage.Value + 1 -- Make the stage leaderstat go up by 1 |
17 |
18 | player.Character.Humanoid.MaxHealth = 0 -- Kills player so they respawn at next check point |
19 | end |
20 | end |
You accidentally changed the MaxHealth, not the players actual Health
01 | local MarketplaceService = game:GetService( "MarketplaceService" ) |
02 | local RemoteEvent = game.ReplicatedStorage.PromptSkipStagePurchase |
03 | local productId = 1164319291 |
04 |
05 | -- Prompt purchase |
06 | RemoteEvent.OnServerEvent:Connect( function (player) |
07 | MarketplaceService:PromptProductPurchase(player, productId) |
08 | end ) |
09 |
10 | -- Skip function |
11 | MarketplaceService.ProcessReceipt = function (receiptInfo) |
12 | if receiptInfo.ProductId = = productId then |
13 |
14 | local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId) |
15 |
16 | player.leaderstats.Stage.Value = player.leaderstats.Stage.Value + 1 -- Make the stage leaderstat go up by 1 |
17 |
18 | player.Character.Humanoid.Health = 0 -- Kills player so they respawn at next check point |
19 | end |
20 | end |