Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
znepb 17
7 years ago

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

Log in to vote
1
Answered by
Newrown 307 Moderation Voter
7 years ago
Edited 7 years ago

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! :)

0
Worked! Thank you for helping! znepb 17 — 7y
0
My pleasure Newrown 307 — 7y
Ad

Answer this question