So, I'm making a player searching system. I have made it so it uses the GetPropertyChangedSignal and whenever a new letter is typed it, in loops through the player list to check if the player is already in the game. However, is there a more efficient way to do this instead of every letter that is typed in it doesn't check through all of the players? I believe that this would make the game slower and possibly cause a lot of lag. Here is the code that I have got so far:
local player = game.Players
local enterUsername = script.Parent.enterUsername
script.Parent.enterUsername:GetPropertyChangedSignal("Text"):connect(function()
for i,v in pairs(player:GetChildren()) do
if v.Name == enterUsername.Text then
print("Hello")
end
end
end)

2 comments
Have the player click a button once they type the username instead of constantly checking when they've typed it
Yeah, that was the solution that I went for.