I'm creating a custom admin script and I'm at lost with finding abbreviated names.
This is what I currently have where you have to type the full username.
function findPlayer(name)
local players = {}
for _, player in ipairs(game.Players:GetPlayers()) do
-- if Data[player.Name .. "'s Data"].FakeName.Value:lower() == name:lower() then --
if player.Name:lower() == name:lower() then
table.insert(players, player)
end
end
if "all" == name:lower() then
for i,v in pairs(game.Players:GetPlayers()) do
table.insert(players, v)
end
end
return players
end
In addition I want to also index fake usernames that will often times have spaces in them or maybe even be similar.
Ex: We have three fake names in game: Sarah Law, Sarah Lau, and Jimmy Neutron
:Kill Jimmy - kills Jimmy Neutron
:Kill Sarah - returns invalid because there are two names starting with sarah
:Kill Sarah Law - kills stated name

3 comments
Don't use names for admin commands, use UserId
I have, this is for finding in-game players. ":Kill Sarah L" I want this to be able to find Sarah Law.
oh. for that you'll need string.sub