Trying to access profile description of players

I’m working on making a profile description of players accessible in my scripts but I don’t think its possible.

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local HttpService = game:GetService("HttpService")

local Signals = ReplicatedStorage.Signals
local Functions = Signals.Functions

Functions.ToServer.OnServerInvoke = function(player,signal,userInfo)
	if signal == "GetDescription" then
		local url = "https://www.roblox.com/users/" .. userInfo.Id .. "/profile"
		local response = HttpService:GetAsync(url)
		local html = response.Body

		local description = string.match(html, "<meta name=\"description\" content=\"(.*)\">")
		return description
	end
end

I tried the script above on the server but I got the error: HttpService is not allowed to access ROBLOX resources.

Does this mean its impossible if the Roblox API won’t allow me?

1 Like

You need to use a proxy as for some reason, the Roblox API doesn’t accept requests from Roblox game servers. A popular proxy is roproxy. You should also be using the actual Roblox APIs instead of scraping the webpage, as it will be faster and more efficient.

Fixed code:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local HttpService = game:GetService("HttpService")

local Signals = ReplicatedStorage.Signals
local Functions = Signals.Functions

Functions.ToServer.OnServerInvoke = function(player, signal, userInfo)
	if signal == "GetDescription" then
		local url = "https://users.roproxy.com/v1/users/" .. userInfo.Id
		local response = HttpService:GetAsync(url)
		local description = HttpService:JSONDecode(response).description

		return description
	end
end
2 Likes

Woah that actually worked I’ll have to look into more of the external APIs.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.