User can't be found outside of game

I am trying to make a whois command where it will show the player information even if the player isn’t in game. So far the command only works if the player is in game;

image

however, I want it to find the player even if they are not in the game. When i search someone with using their ID, it always returns with a error;
image

Script:

			local UserIDSplit = tonumber(split[2]) 
			if UserIDSplit then
				local SearchedPlayer = Players:GetPlayerByUserId(UserIDSplit)
				print("Found: " .. SearchedPlayer.Name)
				print("Account Age: " .. SearchedPlayer.AccountAge .. " days old")
				
				if DeveloperModule.isDeveloper(localPlayer.Name) then
					print(SearchedPlayer.Name .. " Is a developer")
				end
				
				local Ingame = game.Workspace:FindFirstChild(SearchedPlayer.Name)
				if Ingame then
					print("Currently in game")
				else
					print("Not in game server")
				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

If you know, how to fix this. That would be great. Thanks

1 Like

this will return the player’s name from their ID ( if that’s what you are trying to get ):

Players:GetNameFromUserIdAsync(UserIDSplit)

And finding account age of a player, who is not in-game is a bit… complicated.

You have to use roblox’s api for that. I think this might be helpful to you:

Would that work even if the player isn’t in the game?

both of the code pieces stated above will work, even if the player is offline/not in-game

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