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).
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)
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)
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)