Chat Command System Not Running Elseif's

So, we are currently trying to write a chat command system, and we got the :kick command in the code below working:

game.Players.PlayerAdded:Connect(function(plr)
    plr.Chatted:Connect(function(msg)
        local split = msg:split(" ")
        if split[1] == ":kick" then
            local targ = game.Players:FindFirstChild(split[2])
            local reason = split[3]
            if targ then
                if reason then
                    targ:Kick(reason)
                else
                    targ:Kick("No reason provided.")
                print("User kicked | User: "..targ)
                end
        elseif split[1] == ":ban" then
            local targ = game.Players:FindFirstChild(split[2])
            local reason = split[3]
            if targ and reason then
                targ:Kick("You've been banned from "..game.Name.."\n Reason: "..reason)
                print("User Banned | User: "..targ "Reason: "..reason)    
        elseif split[1] == ":kill" then
            local targ = game.Players:FindFirstChild(split[2])
            targ.Character.Head:remove()
            print("User killed | User: "..targ)
        else
            warn("Not a command")        
                    
                end
            end        
        end
    end)
end)

But the problem is, after the check for the kick command is run, it does not run the elseif’s. We have tried everything, but we do not get anything in the output. No errors or prints, nothing.

If anyone knows why neither the ban nor the kill command are working, please let me know, as me and @WakeTheDev have tried everything to fix it.

(Also I’m aware that it is targ:Kick() and not a datastored ban, we just have it as that for testing purposes.)

game.Players.PlayerAdded:Connect(function(plr)
	plr.Chatted:Connect(function(msg)
		local split = msg:split(" ")
		local targ = game.Players:FindFirstChild(split[2])

		if split[1] == ":kick" then
			local reason = split[3]
			if targ then
				targ:Kick(reason or "No reason provided.")
				print("User kicked | User: "..targ)
			end

		elseif split[1] == ":ban" then
			local reason = split[3]
			if targ and reason then
				targ:Kick("You've been banned from "..game.Name.."\n Reason: "..reason)
				print("User Banned | User: "..targ "Reason: "..reason)    
			end

		elseif split[1] == ":kill" then
			targ.Character.Head:remove()
			print("User killed | User: "..targ)

		else
			warn("Not a command")
		end
	end)
end)

Edit: This is a big, improperly indented script and i keep making mistakes in how many end there should be, thus many edits.

Edit2: you could just put the local targ = ... below local split = msg:split(" ")

Edit3: there are many ways you can make a /command system, and this is not a good one.

Ends need to be at the end of every if statement. Ex:

if split[1] == ':kill' then
   print('cool!')
elseif split[1] == ':kick' then
    if split[2] then
       split[2]:Kick()
    end

elseif split[1] == ':ban' then
    print('ban')
end

the most common way to do this is by storing every command in a table

local commands = {}
commands.Kick = function(target, arguments)
	-- Kick command
end
commands.Ban = function(target, arguments)
	-- Ban command
end

Now, to run a specific function (command), you would index it using a string.
Before that, you would check if the prefix is correct. (And if you want, you can also check if they have access to commands)

local split = split.msg(msg, " ")
if not string.sub(split[1],1,1) == ":" then return end

The not is used to invert it. If the prefix matches then it will not return (not stop)

Then, you will also check if that command exists

if commands[string.sub(split[1],2)] then
	
end

If it exists, then you do some stuff here

if commands[string.sub(split[1],2)] then
	table.remove(split, 1) -- Remove
	local target = game.Players:FindFirstChild(split[2]) -- Find player
	if target then -- Does it exist?
		
	end
end

then lastly, you run that function

if commands[string.sub(split[1],2)] then
	table.remove(split, 1)
	local target = game.Players:FindFirstChild(split[2])
	if target then
		table.remove(split, 1) -- Remove again
		commands[string.sub(split[1],2)](target, split) -- Run the function with the given target and split (arguments)
	end
end