I have a simple script that shows your characters face on a GUI. But the thing when you change your character it loads with NA makes it look goofy, is there any way that if it doesn't load it can change it to some random player of my choosing s character?
COMMUNITY QUESTION
Is there anyway to change a failed images picture to that of something that will load?
1 answer
The function to grab their icon has a built-in failure detector. You can use that to check if the icon hasn't loaded and change the image to a default instead.
The function GetUserThumbnailAsync() returns the image as the first parameter, and success as the second. So all we need to do is make a tuple (multiple variables on the same line, I guess is an easy way to explain it) with the function.
local content, isReady = Players:GetUserThumbnailAsync(userId, thumbType, thumbSize)
The above code will store both the player's icon, if it loaded, and a bool value that is true if it actually loaded, and false if not. Below is an example of how to incorporate this into your code.
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local userId = player.UserId
local thumbType = Enum.ThumbnailType.AvatarBust
local thumbSize = Enum.ThumbnailSize.Size352x352
local content, isReady = Players:GetUserThumbnailAsync(userId, thumbType, thumbSize)
if isReady == true then
script.Parent.Image = content
else
script.Parent.Image = "rbxassetid://0" -- default image in case of their icon not loading
end
This discussion is preserved as it was. New answers, comments, and votes are closed.

7 comments
Are you getting it from their profile pic?
Yes
Can you post the code?
local Players = game:GetService("Players") local player = Players.LocalPlayer -- Fetch the thumbnail local userId = player.UserId local thumbType = Enum.ThumbnailType.AvatarBust local thumbSize = Enum.ThumbnailSize.Size352x352 script.Parent.Image = Players:GetUserThumbnailAsync(userId, thumbType, thumbSize)
Do you know what it says the AssetID is when it fails?
Don't you dare try to use an if statement....
The asset is the same,from what I notice