I made a system that should show information about players if you write their username but when I enter the username of other players it does not work but when I enter my username it works
Script:
local TextBox = script.Parent.SearchPlayer
local Back = script.Parent.Back
local Back2 = script.Parent.Back2
local PlayerIcon = script.Parent.PlayerIcon
local UsernameLabel = Back.Username
local DisplayUsernameLabel = Back.DisplayUsername
local AccountAgeLabel = Back2.AccountAge
local UserIDLabel = Back2.UserID
local function GetPlayerInfo(player)
local username = player.Name
local displayUsername = player.DisplayName
local accountAge = (os.time() - player.AccountAge) / 86400
local userId = player.UserId
local playerIcon = game:GetService("Players"):GetUserThumbnailAsync(userId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)
UsernameLabel.Text = "" .. username
DisplayUsernameLabel.Text = "" .. displayUsername
AccountAgeLabel.Text = "" .. math.floor(accountAge) .. " days"
UserIDLabel.Text = "" .. userId
PlayerIcon.Image = playerIcon
end
TextBox.FocusLost:Connect(function()
local playerName = TextBox.Text
local player = tonumber(playerName) and game:GetService("Players"):GetPlayerByUserId(playerName) or game:GetService("Players"):GetPlayerByUserId(game:GetService("Players"):GetUserIdFromNameAsync(playerName))
if player then
GetPlayerInfo(player)
else
UsernameLabel.Text = "N/A"
DisplayUsernameLabel.Text = "N/A"
AccountAgeLabel.Text = "N/A"
UserIDLabel.Text = "N/A"
PlayerIcon.Image = ""
end
end)