Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

roblox not giving player option to purchase gear when touching brick?

Hello, I have made a brick, when a player touches that brick they should be given a option to buy a golden magic carpet. Instead of it saying "would you like to purchase" it just gives a error message when you touch the brick, the code is in a normal script inside the brick. Thanks!

local id = 1016183873

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		local player = game.Players[hit.Parent.Name]
		game:GetService("MarketplaceService"):PromptProductPurchase(player, id)
	end
end)

https://www.youtube.com/watch?v=EJjdAMDBkIA

4 comments

0

Well, make sure to check your id. I tested your code in Studio, and it worked fine. But, instead of prompting 'Golden Magical Carpet', it showed Billie Eilish clothing.

0

checked the id multiple times and it still seems to promote that

0

Then, try making a new developer product, and replacing the id with the new one.

0

https://www.youtube.com/watch?v=EJjdAMDBkIA youtube link of problem, thank you

1 answer

✓ Accepted answer

From the video, it look likes you are selling items, made by another user. To fix that,

  1. Go to Game Settings in Studio.
  2. Go to Security.
  3. Enabled 'Third-Party' Sales.

Lemme know if it helps!

EDIT : You stated that you are encountering an error, related that your player is not found. To fix that, replace your player variable with :

-- Line 5
local player = game.Players:GetPlayerFromCharacter(hit.Parent)

Also, in Line 6, use PromptPurchase instead of PromptProductPurchase for gears.

7 comments

0

thank you but it is now trying to sell me ruffled shorts instead of a magic carpet, I used the id of the magic carpet but it is trying to sell the player something else, thank you though

0

also i haven't added a magic carpet as a gear item in the game, could it posibly be that. I am trying to make then brick give the player the magic carpet if they buy it !

0

It has a error. There is another error in output that says, " 13:13:20.564 - TGATheGoldenArmour's_7723 is not a valid member of Players "Players" " I have not added any store or gamepasses though.

0

To deal with the error, use GetPlayerFromCharacter. local player = game.Players:GetPlayerFromCharacter(hit.Parent)

0

thank you but please can you put that in a answer so I know where to change lines, also if it solves the issue I can accept it!

0

cheers, made a trailer today of the game https://www.youtube.com/watch?v=3OvvqsRQcOg&feature=youtu.be thank you for your help!

This discussion is preserved as it was. New answers, comments, and votes are closed.