Hello, I’m testing out MarketplaceService and see if I can get the product info and use it
I found the feature, but it seems like it doesn’t work… (the only one that’s working is Icon only)
What’s wrong in this script? (LocalScript):
local MarketplaceService = game:GetService("MarketplaceService")
local Button = script.Parent.Button
local Icon = script.Parent.Icon
local Name = script.Parent.Name
local Description = script.Parent.Description
local ID = 12345
local Asset = MarketplaceService:GetProductInfo(ID, Enum.InfoType.Product)
Icon.Image = "rbxassetid://".. Asset.IconImageAssetId
Name.Text = Asset.Name
Description.Text = Asset.Description
Button.Text = Button.Text.. "[".. tostring(Asset.PriceInRobux).. " Robux]"
Button.MouseButton1Click:Connect(function()
MarketplaceService:PromptProductPurchase(game.Players.LocalPlayer, ID)
end)
Does anyone knows why?
Could you give additional details (screenshots, etc.) on why your code isn’t working, or if you are getting any errors when you run your code?
1 Like
I do found 1 error, lemme screenshot it… (30)
I found one before but the error is gone…
somehow
nvm found it
It says “attempt to index string with “Text””
In line 13
I think it’s because of product name who ruined the script (I think)
you can’t do to name of something .Text beacuse .Name is already string Value so on line 13 just remove the .Text like that:
local MarketplaceService = game:GetService("MarketplaceService")
local Button = script.Parent.Button
local Icon = script.Parent.Icon
local Name = script.Parent.Name
local Description = script.Parent.Description
local ID = 12345
local Asset = MarketplaceService:GetProductInfo(ID, Enum.InfoType.Product)
Icon.Image = "rbxassetid://".. Asset.IconImageAssetId
Name = Asset.Name
Description.Text = Asset.Description
Button.Text = Button.Text.. "[".. tostring(Asset.PriceInRobux).. " Robux]"
Button.MouseButton1Click:Connect(function()
MarketplaceService:PromptProductPurchase(game.Players.LocalPlayer, ID)
end)
1 Like
Do you mean I have to change the name of Name? (TextLabel)
you did on line 13 Name.Text so I assume that you want to change the name of the scriptParent but it
won’t work like that:
Name.Text = Asset.Name
it will work like that:
Name = Asset.Name
1 Like
I fixed it, it’s because I named the TextLabel as Name… but thank you!