Players:getNameFromUserId() failed: Unknown user?

I keep getting this error:

image

And i dony know why, its saying my username is an unknow user. Anyone know why?

Help will be greatly appreciated!

Server:

Players = game:GetService("Players")

event = script.Parent:WaitForChild("RemoteEvent")

event.OnServerEvent:Connect(function(player, Hum, UserName)
	local UserId = Players:GetUserIdFromNameAsync(UserName)
	local Description = Players:GetHumanoidDescriptionFromUserId(UserId)
	print("Applying description...")
	Hum:ApplyDescription(Description)
end)

Client:

function SceneChanged()
	local OldButtons = UsernamesFrame:GetChildren()
	for i, child in ipairs(OldButtons) do
		if child:IsA("TextBox") then
			child:Destroy()
		end
	end
	local Scene = Scenes["Scene" .. CurrentScene.Value]
	local CharactersTable = {}
	for i, Character in ipairs(Scene.Characters:GetChildren()) do
		CharactersTable[i] = Character
		local TextBox = ButtonTemplate:Clone()
		TextBox.Name = Character.Name
		TextBox.Parent = UsernamesFrame
	end
	for i, child in ipairs(UsernamesFrame:GetChildren()) do
		if child:IsA("TextBox") then
			TextBox = child
			TextBox.FocusLost:Connect(function()
				print("Focus lost")
				if TextBox.Text ~= "" and TextBox.Text ~= " " then
					event:FireServer(CharactersTable[TextBox.Name], TextBox.Text)
				end
			end)
		end
	end
end

Capitalize the ‘E’ in your username. The function GetUserIdFromNameAsync() is case-sensitive.

screenshot

It’s not.

image

I have never changed my name to an all-capitalised version of my name before.

And with your name:

image

1 Like

I jumped the gun and got shot down by PA.

/thread

1 Like

Could be related

Try checking the length of UserName to see if there’s a hidden whitespace at the end.

2 Likes

Oh my gosh, your right! Hitting enter creates a space in the text.
I know this because i tried clicking outside the textbox instead of pressing enter and it worked.

Also i selected a space in the error after my user name: image

1 Like

Since you’ve found your solution, I thought I’d add that you should always wrap any website requests with a pcall to avoid your script erroring.

1 Like