Finding names within a text box

So, I’ve been making an admin panel where you can ban, kick, kill, teleport etc. But i want it so you could find users name’s by a shortened piece of text so for example, Instead of using my full name “Mr_Orange08” you could use “Mr_” and it’ll find the user with that starting piece of text in the players folder. If i could have help that’d be nice, Thanks!

You can do that by using string.find
Here’s an example.

function GetPlayer(name)
     name = name:lower()
     for _,v in pairs(game.Players:GetPlayers()) do
         if string.find(v.Name:lower(),name) then
            return v
         end end
end
local plr = GetPlayer("Badly") --> Player BadlyDev
3 Likes

Thanks, Ill try it now. I might have some issues though. I’m not that smart, but that would be not using it properly.