Hey everyone!
I’m trying to make an in-game catalog, but I’m having trouble getting the thumbnail picture of the items I retrieved from the httpService connection, does anyone know what I’m doing wrong?
Client:
local rs = game:GetService("ReplicatedStorage")
local getInfo = rs:WaitForChild("GetcatInfo")
local gui = script.Parent
local search = gui:WaitForChild("SearchBar")
local display = gui:WaitForChild("Display").Display
local box = search:WaitForChild("TextBox")
local button = search:WaitForChild("TextButton")
print("waited")
button.MouseButton1Down:Connect(function()
print("pressed")
getInfo:FireServer()
end)
getInfo.OnClientEvent:Connect(function(info)
print(info)
local data = info.data
for i, v in pairs(data) do
local frame = gui.Parent.Tobecloned.Frame:Clone()
frame.Parent = display
frame.ImageLabel.Image = "https://www.roblox.com/asset-thumbnail/imageassetId="..v.id.."&width=420&height=420&format=png"
end
end)
Server:
local http = game:GetService("HttpService")
local rs = game:GetService("ReplicatedStorage")
local infoRemote = rs:WaitForChild("GetcatInfo")
local info
local succ
local err
function e()
succ, err = pcall(function()
info = http:GetAsync('https://catalog.rprxy.xyz/v1/search/items/details?Category=11')
info = http:JSONDecode(info)
end)
if not succ then
warn(err)
e()
end
end
infoRemote.OnServerEvent:Connect(function(plr)
print("on server")
e()
while not info do
print("not info")
wait()
end
print("returning info")
infoRemote:FireClient(plr, info)
end)
As you can see here, I’m just getting the blank background, no image
Thanks for reading!
At first I would format this differently:
Make GetcatInfo a RemoteFunction instead of a RemoteEvent
--Server
--Variables
local HttpService = game:GetService("HttpService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local InfoRemote = ReplicatedStorage:WaitForChild("GetcatInfo")
--Function to bind to RemoteFunction
function InfoFunction()
local Success, Returned = pcall(function()
return HttpService:JSONDecode(
HttpService:GetAsync('https://catalog.rprxy.xyz/v1/search/items/details?Category=11')
)
end)
if not Success then
warn("An error has occurred:\n" .. Returned .. "\nRetrying..")
wait()
return InfoFunction()
end
return Returned
end
--RemoteFunction
InfoRemote.OnServerInvoke = InfoFunction
--Client
--Variables
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local InfoRemote = ReplicatedStorage:WaitForChild("GetcatInfo")
local Gui = script.Parent
local Display = Gui.Display.Display
local Box = SearchBar.TextBox
local Button = SearchBar:WaitForChild("TextButton")
local Busy = false
Button.MouseButton1Down:Connect(function()
print("Pressed Button")
if Busy then
print("Button is on a cooldown")
return
end
Busy = true
local Info = InfoRemote:InvokeServer(Box.Text)
print("Info received:", Info)
for _, Value in pairs(Info.data) do
local Frame = Gui.Parent.Tobecloned.Frame:Clone()
Frame.Parent = Display
Frame.ImageLabel.Image = "https://www.roblox.com/asset-thumbnail/imageassetId=" .. Value.id .. "&width=420&height=420&format=png"
end
Busy = false
end)
For the rest I am not sure about the API’s, I’ve seen you ask the data for info but gave no argument at all, and a remotefunction makes you able to receive data at the same time, it just yields
Thanks for the idea with the remoteFunction, my main problem was the api though, the link for the thumbnail simply doesn’t work
I would like to help, however I don’t know much about the catalog.rprxy.xyz API.