Need help with thumbnail script

What do you want to achieve? Hey! I am a new coming Roblox scripter, and I am trying to script something where it gets the players UserId, and then it gets the player thumbnail from the UserId, and then the player thumbnail is on an ImageLabel, but it seems to not be working.

What solutions have you tried so far? I have looked all over YouTube, and the developer forum with this issue.

Code Block:

local Players = game:GetService("Players")

local player_id = Players:GetUserIdFromNameAsync()

local Image_id = Players:GetUserThumbnailAsync(player_id, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)

script.Parent.Image = Image_id

I really don’t know what is wrong with it but I keep getting a:

Argument 1 Missing or nil.

in the output.

If anyone can help me solve this problem, that would be very helpful.

You need the player’s username within the parameters

But what if I want to have the image be for the specified client, not a specific player, so you have all of the players specific images on their clients.

1 Like

Do you want the player themselves to have the picture?

Yes, that is exactly what I want.

I’m not entirely understanding the situation, but if you want the player to only see their own picture, then put this code in a localscript, define a variable as the name of the LocalPlayer, and put the variable as the parameter for :GetUserIdFromName

so then use

local players = game:GetService("Players")
local plr = players.LocalPlayer
local player_id = players:GetUserIdFromNameAsync(plr.Name)
local Image_id = Players:GetUserThumbnailAsync(player_id, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)

script.Parent.Iamge = Image_id

basically what @escapethepaw said above

1 Like

Thank you very much, I appreciate the help.

Oh yeah, and get rid of the variable players, since it’s not going to be used.

1 Like

Good catch, I’ll remove it right now.