I am currently working on a load character plugin. I have a slight problem tho: the image is not being showed when you type in the name for the character you want to be loaded in. It works for the first time but not the second, third, etc.
Here is the script:
while wait() do
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
local namebox = script.Parent.Parent.NameBox.Text
local name = getUserIdFromUsername(namebox)
script.Parent.Image = "https://www.roblox.com/Thumbs/Avatar.ashx?x=250&y=250&userId=%22..name
end
The error is on the 24th line, the error is the following:
This is the error: attempt to concatenate string with nil
If anybody knows how to fix this or why its not working, please tell me in the replies!