I am attempting to find a player when only typing in a part of their username in chat, however what I have managed to do is print all the players names if their name had a 'h' in it, if I typed the letter 'h', no matter where in the name it is. I am trying to make it so it reads from the start of the name, not just look for if the name has that specific string anywhere in it.
plr.Chatted:Connect(function(msg)
for _, v in pairs(game.Players:GetPlayers()) do
if v.Name:lower():find(msg:lower(), 1, true) then
print(v.Name)
end
end
end)
Any help is appreciated, thanks.

4 comments
Msg:sub(1)That's redundant: It's the same as without using:sub(1). Also, why not put line 3 before the loop?i forgot lol, and what is wrong with me
Probably the wheather. lol
Worked perfectly, thank you.