How to get a players profile picture when their not in game?

  1. What do you want to achieve?
    I want to set a imageLabel to a player’s profile picture while their not in game.

  2. What is the issue?
    I know how to set a profile picture into a pictureLabel when the player is in a game but while their not in game?
    I have no idea how to do it.

  3. What solutions have you tried so far?
    I looked on the devForum and couldnt find anything similar.

local userId = script.Parent.userID

local thumbType = Enum.ThumbnailType.HeadShot
local thumbSize = Enum.ThumbnailSize.Size420x420
local content, isReady = game.Players:GetUserThumbnailAsync(userId, thumbType, thumbSize)

script.Parent.poster = content

" Unable to cast Instance to int64 - Client - setter:5"
Is the error that comes up and Im guessing its because the player isnt in the game.

local Players = game:GetService("Players")
local UserId = 000000 -- change it to the userID, does not have to be in-game.
local thumbType = Enum.ThumbnailType.HeadShot
local thumbSize = Enum.ThumbnailSize.Size420x420

local success,result = pcall(function()
     return Players:GetUserThumbnailAsync(userId,thumbType,thumbSize)
end)

if success then
    script.Parent.Poster.Image = result
end

1 Like

I totally forgot about the .Image but thanks.

1 Like

Is there any way to get the name too?
I found this on the devForum but it only works if the player is online(in game)

Players:GetPlayerByUserId(userId)

when I print it, it return nil

local success,result = pcall(function()
	return Players:GetPlayerByUserId(userId)
end)

if success then
	script.Parent.name.Text = result
end

https://developer.roblox.com/en-us/api-reference/function/Players/GetNameFromUserIdAsync

2 Likes