if string.find(gui.TextBox.Text,"ff;") then
--local pattern="^ff;%w+"
local match=(gui.TextBox.Text):match("^ff;%w+")
if match then
local var=string.lower(string.match(match,".+",4))
for _,v in pairs(game.Players:GetPlayers()) do
local player=string.lower(v.Name)
if var==string.sub(player,1,4) then
local forcefield=Instance.new("ForceField", v.Character)
end
end
if string.match(gui.TextBox.Text,"^ff;me$") then
local forcefield=Instance.new("ForceField", Char)
end
end
end
So I really want to improve on this, because it truly looks very ugly. But i'm usin it for now (I made it), anyways the problem is the fact that some players have ridiculously long names on purpose, for example: "JohnCenaLover59595959422", and let's say I want to forcefield them, instead of typing that out, can I just make it so I only have to say: ff;john
Thanks!

4 comments
Use string.find to see if a partial string matches the name of a player. For match patterns, putting "^" at the beginning of the string makes it only look if there is a match starting with the first character
Yes after a couple of hours, I improved the code by a lot, it looks very pretty now. The only problem now, is say I want to admin my friend named 'Applesauce', and a user named 'Applesauce5' joins in. If I type admin;Applesauce it will admin both of them, how do I fix that? Thanks!
use break when it loops so the closest matching one will do it and none otehr.
Alternatively, keep track of how many users are affected by a command, and then handle it accordingly. If a command is sensitive, like
admin;[Name], tell the person that issued it that multiple people were found, and then do nothing.