How to Prompt a Catalog Item Purchase?

Hello!

I wanted to make a part that will show a purchase prompt for a Catalog Asset,
But it doesn’t work when I test it.

The Script is a LocalScript:

local ID = 7552354901 -- Shirt ID

script.Parent.Touched:Connect(function()
	local purchasey = game:GetService("MarketplaceService")
	purchasey:PromptPurchase(game.Players.LocalPlayer, ID)
end)

How could I fix this?
(Also API Services is Enabled).

LocalScripts only work if their parent is a player’s character, starterplayerscripts, startercharacterscripts or playergui

Ok, But how can I fix my script from not activating the purchase? I tried anything I searched, It didn’t work as well. And I changed the script to a Server Sided, It still doesn’t work.

script.Parent.Touched:Connect(function(p)
local player = game:GetService("Players"):GetPlayerFromCharacter(p.Parent)
if not player then
return false
else
game:GetService("MarketplaceService"):PromptPurchase(player,7552354901)
end
end)

(In a normal script and the script must be in the part)

It still doesn’t work, I tried using the code in a part in a ServerSided Script.

Try using

script.Parent.Touched:Connect(function(p)
local player = game:GetService("Players"):GetPlayerFromCharacter(p.Parent)
if not player then
return false
else
game:GetService("MarketplaceService"):PromptPurchase(player,7552354901)
end
end)

If that doesn’t work make sure you have Allow Third Party Sales on in the game settings

This won’t work all the time since .Touched returns the part that touched, it’s not always directly a child of a player, instead use:

script.Parent.Touched:Connect(function(p)
if not p:FindFirstAncestorOfClass("Model") then
return
end
local player = game:GetService("Players"):GetPlayerFromCharacter(p:FindFirstAncestorOfClass("Model"))
if not player then
return
else
game:GetService("MarketplaceService"):PromptPurchase(player,7552354901)
end
end)
1 Like

That looks very familiar to the script that is up to your scirpt.

He edited the script to match mine :eyes:

Also you should check Abecreator’s script. And again if that doesn’t work enable third party sales

Thank you very much! The second script actually worked for me Without the Third Party Sales.
Get a Solution.

1 Like

There are probably some errors in the code… idk