Need help with getting player RAP

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
2 Likes

You forgot to call the function at the end of the script.

2 Likes

what do you mean I forgot a function?

1 Like

there’s no getUserRap() at the end of the script.
The function doesn’t get called, so it doesn’t run

2 Likes

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

textLabel.Text = tostring(getUserRap(player.UserId))

Here is the output:
image

1 Like

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.

1 Like

yeah. Ive been having that issue which I thought the pcall would fix, but cant figure out how to fix it. I have literally tried everything for it lol.

1 Like

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.

Try visiting this page in your browser right now (it’s the URL that you’re using in your HttpService request).

This is what you’ll see:

This is also what your script sees. There isn’t any data there for it to read.

1 Like

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.

image

1 Like

rpxy.xyz isn’t a reliable proxy
its most likely experiencing downtime
i recommend trying to create your own proxy server for such a task

1 Like

It’ll randomly work on and off because the server isn’t always busy.

That URL and image that I sent in the last message now show as this:


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.

1 Like

although I have no idea to do that since im still learning about how to HTTP and what not.

1 Like

ok then, what would be a better solution to solving this?

1 Like

I once saw a thread on how to create a proxy server, I’ll post it there once I find it.

1 Like

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.

1 Like

Alright, found it.
Follow this tutorial to create a new proxy server: Fixing HttpService: Make PUT, PATCH, DELETE requests, access response headers, proxy to any site, and more
It will work basically the same as the proxy you are using, except it should be more reliable.
This is the method that I am using for a game that I’m making similar to Trade Hangout and it’s pretty reliable.

1 Like