local HttpService = game:GetService("HttpService")
local bill = game.ServerStorage.BillboardGui
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
local vibez = plr.leaderstats.Vibez
local name = plr.Name
local UserId = plr.UserId
local Endpoint = "https://inventory.rprxy.xyz/v1/users/%d/assets/collectibles"
local Success, Result = pcall(HttpService.GetAsync, HttpService, Endpoint:format(UserId))
local Response = HttpService:JSONDecode(Result)
local TotalRap = 0
for i, Asset in pairs(Response.data) do
if Asset then
TotalRap += Asset.recentAveragePrice
else
TotalRap = 0
end
end
print(TotalRap)
local copy = bill:Clone()
copy.Username.Text = name
copy.Stats.Text = vibez.Value.." Vibez".." - "..TotalRap.." RAP"
copy.Parent = plr.Character.Head
end)
end)
Sometimes when a player has 0 rap or just sometimes in general it says “JSON failed to parse” and it makes it so the whole entire tag doesn’t work. Is there a method so I can retry if it fails to parse or to detect if it fails to parse?
By the way this is a username tag and it looks like this:
local Success, Result, Response
local Count = 0
repeat
Success, Result = pcall(HttpService.GetAsync, HttpService, Endpoint:format(UserId))
Count += 1
wait(0.25)
until Success or Count > 5
if Success then
Result = HttpService:JSONDecode(Result)
else
print("Failed")
end
Can you put it in the entire code? Because I don’t know exactly where to put that or if I’m supposed to be replacing anything, I tried implementing it with the knowledge I know in game and it ended with this.
local HttpService = game:GetService("HttpService")
local bill = game.ServerStorage.BillboardGui
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
local vibez = plr.leaderstats.Vibez
local name = plr.Name
local UserId = plr.UserId
local Endpoint = "https://inventory.rprxy.xyz/v1/users/%d/assets/collectibles"
local Success, Result, Response
local Count = 0
repeat
Success, Result = pcall(HttpService.GetAsync, HttpService, Endpoint:format(UserId))
Count += 1
wait(0.25)
until Success or Count > 5
if Success then
Response = HttpService:JSONDecode(Result)
else
print("Failed")
end
local TotalRap = 0
for i, Asset in pairs(Response.data) do
if Asset then
TotalRap += Asset.recentAveragePrice
else
TotalRap = 0
end
end
print(TotalRap)
local copy = bill:Clone()
copy.Username.Text = name
copy.Stats.Text = vibez.Value.." Vibez".." - "..TotalRap.." RAP"
copy.Parent = plr.Character.Head
end)
end)
Made a slight typo with my previous reply, which was probably why you were getting an error.