So I’m trying to make a script which lets you pay to respawn back where you died with more health. It works well until the
game:GetService("MarketplaceService").PromptPurchaseFinished:connect(function()
part of the script, which it just skips over and doesn’t wait for the player to pay for. Here’s the full portion of the code with the problem:
ContinueReceiver.OnServerEvent:Connect(function()
local Purchases = 0
if Purchases == 0 then
game:GetService("MarketplaceService"):PromptProductPurchase(player, 1150196741)
elseif Purchases == 1 then
game:GetService("MarketplaceService"):PromptProductPurchase(player, 1150196820)
elseif Purchases == 2 then
game:GetService("MarketplaceService"):PromptProductPurchase(player, 1150196876)
elseif Purchases >= 3 then
game:GetService("MarketplaceService"):PromptProductPurchase(player, 1150196958)
end
game:GetService("MarketplaceService").PromptPurchaseFinished:connect(function()
local Purchases = Purchases+1
player:LoadCharacter()
wait (1)
character.UpperTorso.Position.X = DPX
character.UpperTorso.Position.Y = DPY
character.UpperTorso.Position.Z = DPZ
end)
If you don’t understand what I expalined then this video might explain it a little better
You can’t do that with developer products. You have to use MarketplaceService.ProcessReceipt
1 Like
I don’t really understand how to make it work, this is what I have right now, it still jumps directly to MPS and doesn’t let the purchase finish
ContinueReceiver.OnServerEvent:Connect(function()
local Purchases = 0
if Purchases == 0 then
game:GetService("MarketplaceService"):PromptProductPurchase(player, 1150196741)
elseif Purchases == 1 then
game:GetService("MarketplaceService"):PromptProductPurchase(player, 1150196820)
elseif Purchases == 2 then
game:GetService("MarketplaceService"):PromptProductPurchase(player, 1150196876)
elseif Purchases >= 3 then
game:GetService("MarketplaceService"):PromptProductPurchase(player, 1150196958)
end
MPS.ProcessReceipt = function(receiptInfo)
-- 1st Purchase
if receiptInfo.ProductId == 1150196741 then
local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
Purchases = Purchases + 1
wait (1)
character.UpperTorso.Position.X = DPX
character.UpperTorso.Position.Y = DPY
character.UpperTorso.Position.Z = DPZ
-- 2nd Purchase
elseif receiptInfo.ProductId == 1150196820 then
local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
Purchases = Purchases + 1
wait (1)
character.UpperTorso.Position.X = DPX
character.UpperTorso.Position.Y = DPY
character.UpperTorso.Position.Z = DPZ
-- 3rd Purchase
elseif receiptInfo.ProductId == 1150196876 then
local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
Purchases = Purchases + 1
player:LoadCharacter()
wait (1)
character.UpperTorso.Position.X = DPX
character.UpperTorso.Position.Y = DPY
character.UpperTorso.Position.Z = DPZ
-- 4th Purchase
elseif receiptInfo.ProductId == 1150196958 then
local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
wait (1)
character.UpperTorso.Position.X = DPX
character.UpperTorso.Position.Y = DPY
character.UpperTorso.Position.Z = DPZ
end
end
There’s a better way to do this.
I presume you already have soemthing that acts as a container for your Purchases? Like an IntValue in the Player?
I recommend putting the code for prompting the Product in the button for respawning back in and the Processreceipt code outside of the OnServerEvent, which would basically remove the need to use a RemoteEvent.
Also there’s a lot of repeition going on, you may want to organize the code a bit
1 Like