Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to tell if a player isn't in the game?

Asked by 4 years ago

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)
0
remove the "and not v.Name", if you are trying to make it ignore yourself, replace it with "and v.Name ~= Username.Text" Hacreey 49 — 4y
0
Thank you Asynchronize 16 — 4y
0
if not game.Players:FindFirstChild(Username.Text) then Username.Text = "Player not found" end 1waffle1 2908 — 4y

Answer this question