Help with custom commands

I am trying to make a script to make a Gui over someones head after you say a command. I want it to be were if you say :ath (Player’s Name) it make a text above there head say Authorized. I already have the text part done but need to do the part were it finds out who to Authorize. This is what I have but I just got it from a few different yt videos and idk how it works.

local PlayersService = game:GetService("Players");
local StringToDetect = ":ath";

PlayersService.PlayerAdded:Connect(function(Player)
	Player.Chatted:Connect(function(Message)
		if string.find(string.lower(Message), string.lower(StringToDetect)) then
			if Player.Character then
				local fiPlayer = string.sub(Message:lower(), 7)

				for _, v in pairs(game.Players:GetPlayers()) do

					if string.sub(v.Name:lower(), 1, #fiPlayer) == fiPlayer then
						game.Workspace{v}.TastiesOverhead.nametag.Authorised.Text = "Authorized"
					end	
					end
					end;	
		end;
	end);
end);

There’s quite a bit of string manipulation going on, which can be confusing. A few of the variables are pretty confusing as well.

When a player joins, the server listens to the player’s “Chatted” event. When the event fires, the server examines the message sent by the player. If the message contains ‘StringToDetect’ (in this case, “:ath”), then:
We check to make sure the player has a physical character in-game. If the player does have a character, then:
Clip the original message sent by the player so that it no longer contains “:ath”. Theoretically, the remaining text should just be the name of the player we want to authorize.
Iterate through all players currently in the game:
If the player’s name matches the text from the clipped message (which comparation has been modified so that it’s not case-sensitive), then:
Update the player’s text label to say “Authorized”

Personally, I don’t understand why the code suddenly checks if the player has a character in-game. It makes sense if the player uses “:ath” on itself, but if that’s what it’s for, it would make more sense to test that for all players, like so:

for _, v in pairs(game.Players:GetPlayers()) do

    if string.sub(v.Name:lower(), 1, #fiPlayer) == fiPlayer then
        if v.Character then
            game.Workspace{v}.TastiesOverhead.nametag.Authorised.Text = "Authorized"
        end
    end	
end

Ok thanks but what is fiPlayer? is it just the player?

I’m not quite sure what the abbreviation stands for, but fiPlayer is the cropped message that no longer contains “:ath.”