I want to know how to make something like in Trade Hangout where it shows the total amount of rap a player has. But, in order to do this, I learned I had to use This Roblox Api in order to do so. I have no clue about how to incorporate Api into my roblox game. How should I script this? Here is my script now, but it doesnât show rap;
game.Players.PlayerAdded:Connect(function(player)
local stats = Instance.new("Folder",player)
stats.Name = "leaderstats"
local RAP = Instance.new("IntValue",stats)
RAP.Name = "Total RAP"
RAP.Value = "?"
end)
You can access the Roblox APIs through rprxy.xyz. This script gets the total RAP of a player through their user id, made for you.
local httpService = game:GetService("HttpService")
local function GetTotalRAP(userId)
local success, msg = pcall(function()
local total = 0
local function CollectRAP(cursor)
local url = "https://inventory.rprxy.xyz/v1/users/" .. userId .. "/assets/collectibles?sortOrder=Asc&limit=100"
if cursor then
url = url .. "&cursor=" .. cursor
end
local data = httpService:GetAsync(url)
data = httpService:JSONDecode(data)
for i = 1, #data["data"] do
pcall(function()
total = total + data["data"][i]["recentAveragePrice"]
end)
end
if data["nextPageCursor"] then
CollectRAP(data["nextPageCursor"])
end
end
CollectRAP()
return total
end)
if not success then
warn(msg)
else
return msg
end
end
print(GetTotalRAP(game.Players:GetUserIdFromNameAsync("ForegoingTyler12943"))) -- Example
Thanks so much for this script! It works nicely by printing out the amount of rap I have, but what if I wanted the amount of playerâs rap to be displayed in a screengui? How would I have to modify this script to make it work?
Sure, you can set up a simple system where a RemoteFunction is invoked from a LocalScript and the RAP for a player is returned from the server which can be used by the same LocalScript to edit a TextLabel. We do this simply because you canât use HttpService on the client or else your IP can be stolen.
So what you would do is put this function inside the server script and call it whenever the client requests the RAP of a player.
Hey! Just wondering⌠How and where did you get âhttps://inventory.rprxy.xyz/v1/users/â ⌠userId ⌠â/assets/collectibles?sortOrder=Asc&limit=100â. Also what is the parantheses defined as âcursorâ meant to be?
Sorry for the late reply. Unfortunately rprxy.xyz was shut down by the owner. It was basically an alternative url that allowed you to sent HTTP requests to the Roblox web api as you arenât allowed to directly do that on Roblox games. There are probably new alternatives that you may use now or maybe Roblox now allows you to call their web apis. I donât know, it has been a while. Hereâs where I got it: Inventory Api. âcursorâ is important because in a request you can only request up to 100 items owned by the user. If you want to go to the next âpageâ, you include a cursor that is supplied with the last request. This is automatically handled in the script that I wrote. It keeps loading their owned items until it reaches the end.