Trying to make it so when someone types a username in a textbox and that username/player isn't in the game, tell them somehow and return false.

Script I got so far that isn't working:

local Username = script.Parent

local function onEntered(enterPressed)
	if enterPressed then
		for i, v in pairs(game.Players:GetPlayers()) do
			if Username.Text == v.Name and not v.Name then
				Username.Text = "Player Not Found"
			end
		end
	end
end

script.Parent.FocusLost:Connect(onEntered)

3 comments

0

remove the "and not v.Name", if you are trying to make it ignore yourself, replace it with "and v.Name ~= Username.Text"

0

Thank you

0

if not game.Players:FindFirstChild(Username.Text) then Username.Text = "Player not found" end