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

How do I make a button that asks a player to buy a shirt?

I am making a game for my clothing group, and when a user clicks a shirt, it would ask them if they wanted to buy the shirt. Here is my code:

script.Parent.ClickDetector.MouseClick:connect(function(plr)
	-- How do I ask the player if they want to buy the shirt?
end)

1 answer

✓ Accepted answer

It's actually really easy, there is a service called MarketplaceService that you can use to achieve what you want.

There is a function of MarketplaceService that is called PromptPurchase which is what you can use to allow the player to buy any asset.

The first two parameters that PromptPurchase takes is the player object, and the second is the asset Id (Id of the asset on the roblox website, ex: https://www.roblox.com/catalog/139610216/Korblox-Deathspeaker, the id of this would be "139610216").

So lets translate this into code:

local marketplaceService = game:GetService("MarketplaceService")

script.Parent.ClickDetector.MouseClick:connect(function(plr)
    marketplaceService:PromptPurchase(plr, 1234) -- replace 1234 with the id of asset
end)

Hope this helped! :)

2 comments

0

Worked! Thank you for helping!

0

My pleasure

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