How to get over HTTP 403?

Hey. I am currently making an overhead GUI that gets a user’s collectibles, adds up their RAP and displays a rounded number along with the user’s name. The problem I am encountering is that when a player’s inventory is private, it gives me a HTTP 403 forbidden error and stops the whole function, and doesn’t display an overhead GUI at all. Even if a user’s inventory is private, I want to display his username.

local BillboardGui = game:GetService("ServerStorage"):WaitForChild("BillboardGui")
local RAPValue = game:GetService("ServerStorage"):WaitForChild("RAPValue")
local t = 1
game:GetService("StarterPlayer").HealthDisplayDistance = 0
game:GetService("StarterPlayer").NameDisplayDistance = 0


function RoundRAP(Value)
	local RAPString = ""
	if Value >= 1000000 then 
		RAPString = ((string.format("%0.1f", tostring(Value/1000000))) .. "M")
		return RAPString
	elseif Value >= 1000 then
		RAPString = ((string.format("%0.1f", tostring(Value/1000))) .. "K")
		return RAPString
	elseif Value < 1000 then
		RAPString = (tostring(Value))
		return RAPString
	end
end


game.Players.PlayerAdded:Connect(function(player)	
	player.CharacterAdded:Connect(function(character)		
		local ClonedGui = BillboardGui:Clone()
		local ClonedValue = RAPValue:Clone()
		local RAPTable = {}
		local HTTP = game:GetService("HttpService")
		local ID = game.Players:GetUserIdFromNameAsync(player.Name)
		local data = HTTP:GetAsync("https://inventory.rprxy.xyz/v1/users/" .. ID .. "/assets/collectibles", true)
		warn(ID)
		warn(data)
		local DecodedData = HTTP:JSONDecode(data)
		local ItemDataTable = (DecodedData["data"])	
		for i, v in pairs(ItemDataTable) do
			local VTable = (ItemDataTable[i])
			local RAP = (VTable["recentAveragePrice"])
			table.insert(RAPTable, 1, RAP)
		end
		for i, v in pairs(RAPTable) do
			ClonedValue.Value = ClonedValue.Value + v
		end
		ClonedValue.Parent = ClonedGui
		local RAPString = RoundRAP(ClonedValue.Value)
		local UserNameString = (tostring(game.Workspace:WaitForChild(player.Name)))
		ClonedGui.TextLabel.Text = (UserNameString .. " | " .. RAPString)
		ClonedGui.Parent = game.Workspace:WaitForChild(player.Name).Head
		local TweeningInfo1 = TweenInfo.new(t , Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0)
		local TweenObject = ClonedGui.TextLabel
		local Tween1 = game:GetService("TweenService"):Create(TweenObject, TweeningInfo1, {TextColor3 = Color3.new(1, 0, 0)})
		local Tween2 = game:GetService("TweenService"):Create(TweenObject, TweeningInfo1, {TextColor3 = Color3.new(1, 1, 0)})
		local Tween3 = game:GetService("TweenService"):Create(TweenObject, TweeningInfo1, {TextColor3 = Color3.new(0, 1, 0)})
		local Tween4 = game:GetService("TweenService"):Create(TweenObject, TweeningInfo1, {TextColor3 = Color3.new(0, 1, 1)})
		local Tween5 = game:GetService("TweenService"):Create(TweenObject, TweeningInfo1, {TextColor3 = Color3.new(0, 0, 1)})
		local Tween6 = game:GetService("TweenService"):Create(TweenObject, TweeningInfo1, {TextColor3 = Color3.new(1, 0, 1)})
		while true do
			Tween1:Play()
			wait(t)
			Tween2:Play()
			wait(t)
			Tween3:Play()
			wait(t)
			Tween4:Play()
			wait(t)
			Tween5:Play()
			wait(t)
			Tween6:Play()
			wait(t)
		end
	end)
end)

Try using pcall as it wouldn’t stop the whole script. Maybe you can try doing an if check to make it display the username? Try these and let me know if it helps or not.

5 Likes

Thank you so much. pcall is exactly what I was looking for. I can’t believe I was missing something this crucial all this time. Anyway, thank you for your help, my gui is behaving exactly how I want it to be.

1 Like

No worries, I’m glad it helped.

2 Likes