local bloxyColaId = 109367940 script.Parent.ClickDetector.MouseClick:connect(function(player) Game:GetService("MarketplaceService"):PromptPurchase(player, bloxyColaId, false, 2) end)
The code I have above worked fine for a clickdetector in a normal block. But after I moves it to a gui, I changed it around to this:
local assetId = script.Parent.MarketID script.Parent.MouseButton1Down(function(player) Game:GetService("MarketplaceService"):PromptPurchase(player, assetId, false, 2) end)
So all I basically did was make the asset id a string value and the script inside of a gui. Does MarketplaceService not like string values? Please help Responds to this would really be helpful.
Three things :
first, if script.Parent.MarketID is a StringValue object, then, on line 1 you're just defining a reference to the StringValue itself, but not the value property that's inside it. Just add a .Value at the end of the line to fix this. Second, you've removed the :connect()
on line 2. Lastly, you have to define player
, considering that it's not passed as an argument with the MouseButton1Down
function.
Other than that, I don't see anything else wrong in your script. After having fixed these issues, it should look like this :
local assetId = script.Parent.MarketID.Value script.Parent.MouseButton1Down:connect(function() Game:GetService("MarketplaceService"):PromptPurchase(game.Players.LocalPlayer, assetId, false, 2) end)