Setting user's pfp when converted their name to userid

I’m attempting to set a player’s user by getting their username from a textbox, being fired from a RemoteEvent but it seems that it doesn’t function. I had to convert their user to userID, but I may not get it. Any assistance will be appreciated, here’s the script I currently have written:

    local cache = {}
    local plrs = game:GetService("Players")

local function getIDfromText(name)
    if cache[name] then return cache[name] end
    local plr = plrs:FindFirstChild(name)
    if plr then
        cache[name] = plr.UserId
        return plr.UserId
    local id 
        id = plr:GetUserIdFromNameAsync(name)
cache[name] = id
return id 

local function setPfp()

local pfp = plr.PlayerGui.Host.MainFrame.Panel.UserPFP

	pfp.Image = ""..setPfp.."&width=420&height=420&format=png"


The current error I obtain is: ServerScriptService.HostLoader:26: attempt to concatenate function with string

You forgot the brackets! You tried to concatenate your function instead of concatenating what was returned from it.

pfp.Image = "".. setPfp() .."&width=420&height=420&format=png"

Ah! I didn’t realise, thank you. But this error pops up now ServerScriptService.HostLoader:26: attempt to concatenate nil with string.

You need to return what is returned from getIDfromText!

local function setPfp()
	return getIDfromText(txt)
1 Like

Oh my, thank you so much for your assistance! I’m kind of a beginner and I may not realise these simple errors.