Argument 1 missing or nil

Hello! What I am trying to do is a player search and the image of the player appears on my ImageLambel, all good but I get this error everytime i start writing on the text button

What I think is that maybe if the player does not exist it returns nill, but I’m not sure

Here is the code:

local TextBox = script.Parent.Parent.User.TextBox
local Players = game:GetService("Players")

local cache = {}

function getUserIdFromUsername(name)
	if cache[name] then return cache[name] end
	
	local player = Players:FindFirstChild(name)
	if player then
		cache[name] = player.UserId
		return player.UserId
	end 

	local id
	pcall(function ()
		id = Players:GetUserIdFromNameAsync(name)
	end)
	cache[name] = id	
	
	return id
end


TextBox:GetPropertyChangedSignal("Text"):Connect(function()
	wait(0.2)
	local USER = tostring(TextBox.Text)
	
		
	local thumbType = Enum.ThumbnailType.HeadShot
	local thumbSize = Enum.ThumbnailSize.Size180x180
		
	local content, isready = Players:GetUserThumbnailAsync(getUserIdFromUsername(USER), thumbType, thumbSize)
	
	local ImageUser = script.Parent.PlayerImage
	
	
	ImageUser.Image = content
end)

I got the script from this roblox article: (I modified the script)
https://developer.roblox.com/en-us/api-reference/function/Players/GetUserIdFromNameAsync

Image of how it works:
image

image

If the call fails, id will be nil, you need to check that before you supply it to GetUserThumbnailAsync.

TextBox:GetPropertyChangedSignal("Text"):Connect(function()

	wait(0.2)
	local USER = tostring(TextBox.Text)

	local thumbType = Enum.ThumbnailType.HeadShot
	local thumbSize = Enum.ThumbnailSize.Size180x180
	local id = getUserIdFromUsername(USER)

	if id then
		local content, isready = Players:GetUserThumbnailAsync(id, thumbType, thumbSize)
		ImageUser.Image = content
	end
	
end)