Getting information for a player outside of a roblox game

When trying to get certain information to get a player information, such as their account age, what role are they in a certain group etc. It always returns with nil or nothing since they are not in game. If I were to try this with the player in-game it would all work.

I am aware that I need to use some sort of API to get the information outside of the platform however I do not have a clue on how to use the API.

		if command == Prefix .. "w" or command == Prefix .. "whois" then
			local UserIDSplit = tonumber(split[2]) 
			if UserIDSplit then
				local SearchedPlayerName = Players:GetNameFromUserIdAsync(UserIDSplit)
				print("Found: " .. SearchedPlayerName)

				local function SuccessMessageInfo()
					CommandInputBox.TextColor3 = Color3.fromRGB(124, 255, 124)
					CommandInputBox.Text = "Success in finding: " .. SearchedPlayerName .. " from ID: " .. UserIDSplit
					task.wait(4)
					CommandInputBox.TextColor3 = Color3.fromRGB(255, 255, 255)
					CommandInputBox.Text = ""
				end

				task.spawn(SuccessMessageInfo)
				
				local profile = Players:GetPlayerByUserId(UserIDSplit)
				print(profile)

				-- Check if the player is currently in the game
				local SearchedPlayer = Players:GetPlayerByUserId(UserIDSplit)
				if SearchedPlayer then
					if not DeveloperModule.isDeveloper(SearchedPlayer) then
						print(SearchedPlayerName .. " is not a developer")
					else
						print(SearchedPlayerName .. " is a developer")
					end

					local Ingame = game.Workspace:FindFirstChild(SearchedPlayerName)
					if Ingame then
						print("Currently in game")
					else
						print("Not in game server")
					end

					local RankInGroup = SearchedPlayer:GetRankInGroup(groupID)
					print("Community Group Role: " .. (RankInGroup or "Guest"))
				else
					print(SearchedPlayerName .. " is not currently in the game")

					if not DeveloperModule.isDeveloper(SearchedPlayerName) then
						print(SearchedPlayerName .. " is not a developer")
					else
						print(SearchedPlayerName .. " is a developer")
					end

				end
			else
				CommandInputBox.TextColor3 = Color3.fromRGB(255, 124, 124)
				CommandInputBox.Text = "You must input the player's user ID instead."
				task.wait(4)
				CommandInputBox.TextColor3 = Color3.fromRGB(255, 255, 255)
				CommandInputBox.Text = ""
			end
		end

Use HTTPService to get the players account info through a proxy.

3 Likes

Like @AlexPalex178 said, some information will need to be obtained via a proxy. However, there are some that can be obtained through other methods:

  • UserId (from name, which I see you have already used)
  • Name (from UserId)
  • User Thumbnail
  • User Ban History (new ban API)
  • Rank in group (Player:GetRankInGroup(groupId), i see you used it)

Hope this helps, any of the methods here ending in Async will need to be wrapped in a pcall as they are asynchronous network requests that can fail.

@AlexPalex178 @12345koip, What would the HTTPs Service look like for the group for a example. So like how would I gather the player information from a group through HTTP service and what proxy would you recommend.

What information do you need from the group? Player:IsInGroup() and Player:GetRankInGroup() should surely work (edit: nevermind i realise they wont be in the game).

As for the retrieval, I don’t know what proxy to use as I don’t tend to use the HttpService, but here is what the structure might look like:

local httpService = game:GetService("HttpService")

local link = "https://" --finish the link with your link

--make the request
local success, response = pcall(httpService.GetAsync, httpService, link)
if success then
    --it worked. Decode the response from the proxy. It should end up as a table.
    response = httpService:JSONDecode(response)
end

All I need from the group is their role, however in the current script it doesn’t display the output and returns back to nil

What’s the context for this? It may be better to save a player’s rank to a DataStore and read from there depending on the needs.

Basically its a command that search up player information even if they are not in the game server. However now thinking about how hard it is now, might just make it so it only works with the players that are current in the game server and not that are outside the server

What would you recommend, having it search players outside of the game server or just have it in game server players only

If you own the group, you can search manually through rank names anyway. If it was me making this system, I’d have it so you can retrieve data store information and other things that can be done without HTTP requests and only do this, without really going out of your way to save it to a store. It’s up to you, though. You’d need to look into some proxys.

1 Like