Hello
I have an issue where I keep getting "MarketplaceService:getProductInfo()" failed because HTTP 400 (bad request) as an error or the TextLabel will want a string instead of a variable to change the text to. That is a problem as I am making a game for me and my friends to play on.
My plan was to get a PlaceID, and get info to teleport players to the game and display extra things like the game name or thumbnail (thumbnail and teleport already works, but not game name)
Any help is appreciated
Script
local TeleportService = game:GetService("TeleportService")
local MarketplaceService = game:GetService("MarketplaceService")
while wait(10) do
local rnger = math.random(100000, 3000000000)
local PlaceID = rnger
local thumbnail = "https://assetgame.roblox.com/Game/Tools/ThumbnailAsset.ashx?aid="..PlaceID .."&fmt=png&wd=420&ht=420"
local surfacegui = script.Parent.Parent.SurfaceGui
local Placename = MarketplaceService:GetProductInfo(PlaceID)
surfacegui.Thumbnail.Image = thumbnail
surfacegui.PlaceName.Text = "Placename"
script.Parent.MouseClick:Connect(function(player)
TeleportService:Teleport(PlaceID, player)
end)
end
The reason youâre likely getting that error is because that assetId doesnât exist. With this method youâre doing, youâre likely to get that error quite often. What you could do is wrap that in a pcall() that way when it does error, it doesnât break the script:
local TeleportService = game:GetService("TeleportService")
local MarketplaceService = game:GetService("MarketplaceService")
local GetInfo = function(id)
local PlaceID = id
local thumbnail = "https://assetgame.roblox.com/Game/Tools/ThumbnailAsset.ashx?aid="..PlaceID .."&fmt=png&wd=420&ht=420"
local surfacegui = script.Parent.Parent.SurfaceGui
local Placename = MarketplaceService:GetProductInfo(PlaceID)
surfacegui.Thumbnail.Image = thumbnail
surfacegui.PlaceName.Text = "Placename"
return PlaceID
end
while wait(10) do
local rnger = math.random(100000, 3000000000)
local success, PlaceId = pcall(function()
return GetInfo(rnger)
end)
if success then
script.Parent.MouseClick:Connect(function(player)
TeleportService:Teleport(PlaceId, player)
end)
else
print('invalid')
end
end
How did Super Place Roulette do it? They were able to get the place name.
Any how, I will be getting off for now. I might be able to see the new responses in approximately 8(ish) hours.
local TeleportService = game:GetService("TeleportService")
local MarketplaceService = game:GetService("MarketplaceService")
local GetInfo = function(id)
local PlaceID = id
local thumbnail = "https://assetgame.roblox.com/Game/Tools/ThumbnailAsset.ashx?aid="..PlaceID .."&fmt=png&wd=420&ht=420"
local surfacegui = script.Parent.Parent.SurfaceGui
local Placename = MarketplaceService:GetProductInfo(PlaceID)
surfacegui.Thumbnail.Image = thumbnail
surfacegui.PlaceName.Text = "Placename"
return PlaceID
end
local function GetRandomPlace()
local rnger = math.random(100000, 3000000) -- don't set this too high as it'll cause math.random() to break
local success, PlaceId = pcall(function()
return GetInfo(rnger)
end)
if success then
script.Parent.MouseClick:Connect(function(player)
TeleportService:Teleport(PlaceId, player)
end)
else
GetRandomPlace()
end
end
while task.wait(10) do
GetRandomPlace()
end
I would say itâs because when you definte ârngerâ you are using a maximum value of 3000000000, and no placeIds go anywhere near 3000000000. This means that a lot of the time you are generating a placeId of a place that doesnât actually exist.
Try using this code:
local TeleportService = game:GetService("TeleportService")
local MarketplaceService = game:GetService("MarketplaceService")
while wait(10) do
local rnger
local PlaceID
local success
repeat
rnger = math.random(100000, 900000)
PlaceID = rnger
success = pcall(function()
return MarketplaceService:GetProductInfo(PlaceID)
end)
task.wait()
until success
local thumbnail = "https://assetgame.roblox.com/Game/Tools/ThumbnailAsset.ashx?aid="..PlaceID .."&fmt=png&wd=420&ht=420"
local surfacegui = script.Parent.Parent.SurfaceGui
local Placename = MarketplaceService:GetProductInfo(PlaceID)
surfacegui.Thumbnail.Image = thumbnail
surfacegui.PlaceName.Text = "Placename"
script.Parent.MouseClick:Connect(function(player)
TeleportService:Teleport(PlaceID, player)
end)
end
Thatâs because you just have it set to setting the name as âPlacenameâ and youâre not actually using your Placename variable + GetProductInfo() doesnât return a string â it returns a dictionary. Youâd have to change it to this:
First, change this line
local Placename = MarketplaceService:GetProductInfo(PlaceID)
to
local Info = MarketplaceService:GetProductInfo(PlaceID)