How do I make a ban command

I am trying to make a ban command that when you type ;ban perm it will permanently ban the person.

Current code:

local commands = {
    ban = function(speaker, args, msg) --ban command
		local plrBan = args[1]
		local banDuration = args[2]

		if plrBan then
			local plrs = findPlayerOutside(plrBan, speaker) --Getting player with userid

			for _, plr in pairs(plrs) do
				print(plr)
				if plr ~= speaker then
					if not string.lower(banDuration) == "perm" or not string.lower(banDuration) == "permanent" then
						local data = {
							start = os.time,
							duration = math.huge,
							reason = string.sub(msg, string.len(prefix.."ban "..args[1].." "..args[2].." "))
						}

						local success, errormessage = pcall(function()
							banData:SetAsync("User_"..plr.UserId, data)
						end)

						if success then
							print("Successfully banned "..plr.Name..": ".."Reason: "..data.reason.." Time left: "..os.time - data.start.." days")
						else
							print("Error banning "..plr.Name.."! ErrorMessage: "..errormessage)
						end

						plr:Kick("You are permanently banned for: "..data.reason.." Time left: "..os.time - data.start.." days")
                    end
				end
			end
		end
	end,
	
	unban = function(speaker, args, msg)
		local plrUnban = args[1]

		if plrUnban then
			local plr = findPlayerOutside(plrUnban, speaker)

			if plr then
				local data = {
					start = nil,
					duration = nil,
					reason = nil
				}

				banData:SetAsync("User_"..plr.UserId, data)
			end
		end
	end
}

return commands

I don’t get any errors when I test but it still doesn’t work.