Hey there, Im currently working on a game that gets the players rap, but im hitting a issue with my code. What im trying to do is get the players RAP [Recent Average Price] but its not working. What I want it to do is if the players inventory is private then return “Private Inventory”, then if its not its supposed to return the players RAP [Recent Average Price]. Its not working so any advice would be great thanks.
Code:
local HttpService = game:GetService("HttpService")
function getUserRap(UserId)
local TotalRAP = 0
local success, errorMessage = pcall(function(check)
local URL = string.format("https://inventory.rprxy.xyz/v1/users/%d/assets/collectibles?sortOrder=Asc&limit=100", UserId)
local Data = HttpService:GetAsync(URL)
local DecodedData = HttpService:JSONDecode(Data)
for _, Item in ipairs(DecodedData.data) do
TotalRAP = TotalRAP + Item.recentAveragePrice
end
return TotalRAP
end)
if success then
print("Inventory Not Private")
return TotalRAP
else
print("Inventory Private")
return "Inventory Private"
end
end
no it gets called in the text label im using, and it works but some times it crashes and says my inventory is private even though its not. @smellfish_360@Grayseon
On line 7 you created an errorMessage variable for the result of the pcall. On line 33 it’d have been more useful to print(errorMessage) so that you can see what’s causing it to fail.
The pcall in this situation only tells your script to ignore any error it might get and continue running without breaking the rest of the script, it doesn’t actually prevent the problem itself.
You can’t do anything about this issue, though, if you want to use this proxy. It’s just a matter of the server you’re using hitting their limits.
whats really weird is I just tried it again and its working and it was getting the RAP but the image failed. Is there some way to to stop the too many HTTP requests? Im not even sending tons.
That’s actually viable data for your script to read.
It isn’t about YOU specifically as an individual sending too many requests. Their servers are just likely busy in general from all of the people that are using it collectively sending requests.
Find a different proxy to use or, if you really want it to be as reliable as you need it to be, you’d have to do what @CentiDev said and just create your own.
Edit: I can’t offer any help there, never done it.