local MarketPlace = game:GetService(“MarketplaceService”)
Server:
MarketPlace.ProcessReceipt = function(receiptInfo)
if receiptInfo.ProductId == 1148820865 then
local plr = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
local Tank = game.ReplicatedStorage.TankSpawn.Tank:Clone()
Tank.Parent = game.Workspace.Cars
plr.Character.Humanoid.MaxHealth = 101
plr.Character.Humanoid.Health = 101
for i,v in pairs (game.Players:GetChildren()) do
v.Character.Humanoid.Health -= 100
end
plr.Character.Humanoid.Health = 100
plr.Character.Humanoid.MaxHealth = 100
spawn(function()-- create a new thread so wait(7) doesnt interupt anything else in the script
wait(7)
Tank:Destroy()
end)
return Enum.ProductPurchaseDecision.PurchaseGranted
else
return Enum.ProductPurchaseDecision.NotProcessedYet
end
end
LocalScript: local id = 1146971176
local mps = game:GetService("MarketplaceService")
local plr = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
mps:PromptProductPurchase(plr, id)
end)
What about it is not working? Please provide context, any error messages and all relevant information needed in the thread itself rather than throwing all your code down and hoping someone does the work for you figuring out what’s wrong and spoonfeeding a solution. Also, try to edit previous responses if you can to include new information rather than cluttering the replies with one-line sentences.
Okay. Have you done any debugging on this code then? For example, simply putting print statements around your code to check what is and isn’t running. You should also be doing debugging too, not just relying on error messages to show what’s not working.
MarketPlace.ProcessReceipt = function(receiptInfo)
if receiptInfo.ProductId == 1148820865 then
print("Starts")
local plr = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
print("GetsPlayer")
local Tank = game.ReplicatedStorage.TankSpawn.Tank:Clone()
Tank.Parent = game.Workspace.Cars
print("ClonesTank")
plr.Character.Humanoid.MaxHealth = 101
plr.Character.Humanoid.Health = 101
for i,v in pairs (game.Players:GetChildren()) do
v.Character.Humanoid.Health -= 100
end
plr.Character.Humanoid.Health = 100
plr.Character.Humanoid.MaxHealth = 100
print("KillsEveryoneElse")
spawn(function()-- create a new thread so wait(7) doesnt interupt anything else in the script
wait(7)
Tank:Destroy()
print("DestroysTank")
end)
return Enum.ProductPurchaseDecision.PurchaseGranted
else
return Enum.ProductPurchaseDecision.NotProcessedYet
end
end
The ID on the server doesn’t match up with the client. I can tell from your responses here, that you’ve done minimal work to debug your program.
Please first work through your program, diagnose what the problem is exactly and provide thorough context when asking questions here. This issue could’ve been resolved with minimal testing on your part.
MarketPlace.ProcessReceipt = function(receiptInfo)
if receiptInfo.ProductId == 1146971176 then
print("Starts")
local plr = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
print("GetsPlayer")
local Tank = game.ReplicatedStorage.TankSpawn.Tank:Clone()
Tank.Parent = game.Workspace.Cars
print("ClonesTank")
plr.Character.Humanoid.MaxHealth = 101
plr.Character.Humanoid.Health = 101
for i,v in pairs (game.Players:GetChildren()) do
v.Character.Humanoid.Health -= 100
end
plr.Character.Humanoid.Health = 100
plr.Character.Humanoid.MaxHealth = 100
print("KillsEveryoneElse")
spawn(function()-- create a new thread so wait(7) doesnt interupt anything else in the script
wait(7)
Tank:Destroy()
print("DestroysTank")
end)
return Enum.ProductPurchaseDecision.PurchaseGranted
else
return Enum.ProductPurchaseDecision.NotProcessedYet
end
end
local id = 1146971176
local mps = game:GetService("MarketplaceService")
local plr = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
mps:PromptProductPurchase(plr, id)
end)
Please spend a bit more time rifling through all your code and debugging. All this could have been solved very quickly if you provided details from the start and if you had checked your own code first before posting to the forum. Also, again, the DevForum isn’t an IM like Discord, please try and condense your replies into as little posts as possible.