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

Do GUIs that use MarketplaceService allow you to use string values?

Asked by 10 years ago
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.

1 answer

Log in to vote
0
Answered by
Asleum 135
10 years ago

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 MouseButton1Downfunction. 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)
0
I tried this in my script. But it does not work out. The output says that on line 3 there is an error and the error says "Unable to cast value to Object." Can you please help me resolve this issue? Someguy1002 0 — 10y
0
Looks like you've also forgotten to define "player" ! I'll update this message in a second Asleum 135 — 10y
0
I tried it out. It still does not work. Someguy1002 0 — 10y
Ad

Answer this question