Im trying to make a Gui that you can click on and you can buy something. It is a regular script and a Textbutton inside a ScreenGui, inside the StarterGUI. The script is...
1 | local assetId = 27112438 --Insert any object Id |
2 |
3 | script.Parent.TextButton.MouseButton 1 Down:connect( function (player) --If true connect the function player |
4 | Game:GetService( "MarketplaceService" ):PromptPurchase(player, assetId) |
5 | end ) |
The player is not passed as an argument when the MouseButton1Down
event fires.
1 | local assetId = 27112438 --Insert any object Id |
2 |
3 | local player = script.Parent.Parent.Parent |
4 | while not player:IsA( "Player" ) do player = player.Parent end --Keep going up until we find the player |
5 |
6 | script.Parent.TextButton.MouseButton 1 Down:connect( function () |
7 | game:GetService( "MarketplaceService" ):PromptPurchase(player, assetId) |
8 | end ) |
1 | local bloxyColaId = 164625523 --id of product or gamepass if its produt, its productid |
2 | local player = game.Players.LocalPlayer |
3 |
4 | function onClick() |
5 | Game:GetService( "MarketplaceService" ):PromptPurchase(player, bloxyColaId) |
6 | end |
7 |
8 | script.Parent.MouseButton 1 Click:connect(onClick) |
9 | --this goes in a local script |