A player has typed a username into a textbox how can I check if that player is in the game?
1 Like
local textbox = script.Parent
textbox.FocusLost:Connect(function()
local text = textbox.Text
if game.Players:FindFirstChild(text) then
print("Player found!")
end
end)
Local script inside the textbox.
Loop through players and check if their name matches the text.
local players = game:GetService("Players");
local function findPlayer(s)
for _, player in ipairs(players:GetPlayers()) do
if (player.Name == s) then
return player;
end
end
return nil;
end
findPlayer("Player1");