Marketplaceservice not properly working

Disclaimer: I am not an expert at all.

I made a script to prompt a purchase of an item based on touch.
The item is uploaded by my group, the game is uploaded directly under my main account. the item is new and for sale.
The script works for my main (i get a prompt that I already own the item)
But nothing is triggered when I don’t play with my main, so no one can buy it in-game.

Does anyone know what might be the cause of this?
This is my code

-- Get the ID of the item you want to prompt the player to purchase
local itemId = 123456789 -- Replace with the actual ID of the item

-- Function to handle when a player touches the part
local function onTouch(other)
   -- Check if the object touching the part is a player
   local character = other.Parent
   local player = game.Players:GetPlayerFromCharacter(character)

   if player then
   	-- Prompt the player to purchase the item
   	game:GetService("MarketplaceService"):PromptPurchase(player, itemId)
   end
end

-- Connect the function to the part's Touch event
script.Parent.Touched:Connect(onTouch)

Just to make sure, do u have 3rd party sales turned on

Ensure third-party sales is toggled on and that the item’s sale location is enabled for your game.

Here’s a slightly modified version of your code

--// Services
local plrs = game:GetService("Players")
local mp = game:GetService("MarketplaceService")

-- Vars
local ItemId = 123456789 -- Replace with the vaild Id of the item

--// Code
script.Parent.Touched:Connect(function(h)
   local plr=nil
   pcall(function()plr=plrs[h.Parent.Name]end)
   if plr then
      mp:PromptPurchase(plr,ItemId)
      -- if its a developer product use mp:PromptProductPurchase()
      -- if its a gamepass use mp:PromptGamePassPurchase()
   end
end)

Make sure to replace the ItemId to the actual Id of the item.

Thanks this solved it, I tried to google possible solutions but only found information on how to make a game pass. Thanks alot!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.