Prompt product failed, something went wrong

  1. What do you want to achieve? Keep it simple and clear!

Alright, so I’m trying to make something like when player click on a part which is the button it prompt them to purchase the product and if the player bought it a sound will play then the script will wait 20 seconds before printing out tween is starting and then it will begin tweening a part and kill all player.

  1. What is the issue? Include screenshots / videos if possible!\

the tweening part works but the problem is that after I click on the button it says Your purchase failed because something went wrong

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I tried doing research on google and developer forum for like solutions to my script but I could not seems to find a way through to fix it.

local ProductID = 2609739727
local Sound = game.Workspace.Siren
local Player = Instance.new("ClickDetector", game.Workspace.Button)
local MarkPlaceService = game:GetService("MarketplaceService")

Player.MouseClick:Connect(function(player)

	MarkPlaceService:PromptProductPurchase(player, ProductID)

	if MarkPlaceService:PlayerOwnsAsset(player, ProductID)then

		Sound:Play()

		wait(20)

		print("Tween is starting..")

		local Call = game.Workspace.Call
		local TWS = game:GetService("TweenService")
		local TweenPart = game.Workspace.TweenPart

		local mation = TweenInfo.new(
			1,
			Enum.EasingStyle.Sine,
			Enum.EasingDirection.Out,
			0,    
			true,
			0
		)

		local PropertiesGoal = {
			Size = Vector3.new(120*2, 98*2 , 122*2);
			Color = Color3.new(1, 0, 0);
			Transparency = .5;
		}

		local Bigger = TWS:Create(TweenPart, mation, PropertiesGoal)

		wait(30)
		Bigger:Play()

		Call.CanCollide = false
		print("Call is now Collidable!")

		TweenPart.Touched:Connect(function(hit)
			local Humanoid = hit.Parent:FindFirstChild("Humanoid")
			if Humanoid then
				Humanoid.Health = 0
				Sound:Stop()
			end
		end)
	end
end)

I really hope someone could help me :confused:

I specialize in building, but I do have some experience with programming.

Try using an IntValue and put the product id in the value. Change the script so that it takes the product id from the IntValue. I don’t know how to word this but maybe try
local ProductID = Game.Workspace.IntValue.Value

Something like that, your a scripter, but im using my work.

What I’m trying to explain is that you should add to the script a line that takes the value from the IntValue.

If that doesn’t work, try getting a new dev product.

I’m sorry if this info is wrong, but I’m trying to give as much help because I know how frustrating these things are.

Using the id in his script is completely okay.

probably a problem with internet maybe also make sure that dev product is made in that game as you can prompt a dev product of other game

The PlayerOwnsAsset function can not be used on developer products. (MarketplaceService | Roblox Creator Documentation)

There are 2 ways to go about this:

Firstly if this is a one time purchase you can use a datastore to store the purchase and check if the player has purchased it before every time they click the button. Developer Products | Roblox Creator Documentation, shows you how to do this.

Secondly, if this is not a one time purchase. You need to handle it like a developer product and not an asset in a player’s inventory. Simply add the following script to ServerScriptService:

local MarketplaceService = game:GetService("MarketplaceService")
local Sound = game.Workspace.Siren
local Players = game:GetService("Players")

local function processReceipt(receiptInfo)
    local player = Players:GetPlayerByUserId(receiptInfo.PlayerId)
    if not player then
    	return Enum.ProductPurchaseDecision.NotProcessedYet
    end
    	
    if receiptInfo.ProductId == 2609739727 then
    	local RunTween = coroutine.create(function()
			Sound:Play()

			wait(20)

			print("Tween is starting..")

			local Call = game.Workspace.Call
			local TWS = game:GetService("TweenService")
			local TweenPart = game.Workspace.TweenPart

			local mation = TweenInfo.new(
			1,
			Enum.EasingStyle.Sine,
			Enum.EasingDirection.Out,
			0,    
			true,
			0
			)	

			local PropertiesGoal = {
			Size = Vector3.new(120*2, 98*2 , 122*2);
			Color = Color3.new(1, 0, 0);
			Transparency = .5;
			}

			local Bigger = TWS:Create(TweenPart, mation, PropertiesGoal)

			wait(30)
			Bigger:Play()

			Call.CanCollide = false
			print("Call is now Collidable!")

			TweenPart.Touched:Connect(function(hit)
				local Humanoid = hit.Parent:FindFirstChild("Humanoid")
				if Humanoid then
					Humanoid.Health = 0
					Sound:Stop()
				end
			end)
		coroutine.resume(RunTween)
    	return Enum.ProductPurchaseDecision.PurchaseGranted
    end
end

MarketplaceService.ProcessReceipt = processReceipt

Hope this helps.

Edit: Changed the script so that it runs the tween function and grants the purchase at the same time otherwise it might run the whole function before granting the purchase.

2 Likes