Error When Selecting Item

I was hoping not to have to post again so soon but the minions of RPG Maker Hell have once again spewed forth another unexplained glitch. Thankfully this time I know exactly which script is causing it. It's the 'Target One Ally (Not The User)' script by Sixth. Which I'll provide below:
Code:
=begin
 
- Target One Ally (Not the User) Scope - What a silly title!
- Made by: Sixth
 
- Description
 
This script will let you make a new scope for your skills (kinda).
That scope will let the player target anyone from an ally except the user.
 
To make a skill use this scope, make sure to set it's database scope to
the "One Ally" type, and use this note-tag in it's note-box:
 
  <one_ally_no_user>
 
This will setup the new scope for the skill. It will work in the menu outside
the battles too, but only on skills.
Due to how the user is set for the items in the item menu (the member with the
highest PHA stat will be the user every time you use an item), it wouldn't make
much sense to enable this new scope there (but if you still used the mentioned
note-tag on an item with the "One Ally" scope, it will function as expected
during battles, so the user will not be able to use the item on him/herself.
 
As a necessary fix, I also made enemies not target the last troop member every
time they use a skill with the "One Ally" scope. Instead, they will now target
random allies, but if the used skill got the <one_ally_no_user> note-tag, they
won't be able to target themselves with the skill.
 
This is tested without any custom battle scripts, so there is no guarantee that
it will work with those!
 
=end
 
class RPG::UsableItem < RPG::BaseItem
 
  attr_accessor :one_no_user
 
  def one_no_user
    init_one_no_user if @one_no_user.nil?
    return @one_no_user
  end
 
  def init_one_no_user
    @one_no_user = @note =~ /<one_ally_no_user>/i ? true : false
  end
 
end
 
class Game_Action
 
  alias check_no_user1232 targets_for_friends
  def item_target_candidates
    trgs = check_no_user1232
    trgs.delete(subject) if item.one_no_user && item.for_one?
    return trgs
  end
 
  alias check_no_user1132 targets_for_friends
  def targets_for_friends
    if subject.is_a?(Game_Enemy) && item.scope == 7
      ids = []
      friends_unit.alive_members.each_with_index do |mem,i|
        next if item.one_no_user && mem == subject
        ids << $game_troop.members.index(mem)
      end
      @target_index = ids.sample
    end
    trgs = check_no_user1132
    return trgs
  end
 
end
 
class Game_BattlerBase
 
  alias check_no_user7541 usable?
  def usable?(item)
    return false if item.one_no_user && friends_unit.alive_members.size <= 1
    check_no_user7541(item)
  end
 
end
 
class Game_Actor < Game_Battler
 
  alias check_no_user9265 item_test
  def item_test(user, item)
    return false if item.one_no_user && self == user
    check_no_user9265(user, item)
  end
 
end
 
class Window_BattleActor < Window_BattleStatus
 
  def draw_actor_name(actor, x, y, width = 112)
    if BattleManager.actor && BattleManager.actor.input.item.one_no_user &&
       actor == BattleManager.actor
      act_enable = false
    else
      act_enable = true
    end
    change_color(hp_color(actor),act_enable)
    draw_text(x, y, width, line_height, actor.name)
  end
 
  def current_item_enabled?
    if BattleManager.actor && BattleManager.actor.input.item.one_no_user &&
       $game_party.members[@index] == BattleManager.actor
      return false
    else
      super
    end
  end
 
end
 
class Scene_Skill < Scene_ItemBase
 
  alias check_no_user8826 use_item
  def use_item
    if item.one_no_user && user == $game_party.members[@actor_window.index]
      return Sound.play_buzzer
    end
    check_no_user8826
  end
 
end
 
class Scene_Battle < Scene_Base
 
  alias check_no_user5413 on_actor_ok
  def on_actor_ok
    if BattleManager.actor.input.item.one_no_user &&
       BattleManager.actor == $game_party.battle_members[@actor_window.index]
      return Sound.play_buzzer
    end
    check_no_user5413
  end
 

    end
What's happening is every time I select 'Item' from the in-battle menu, or if I try to select a blank item slot (if I have an empty inventory) in the main menu out of battle, the game crashes and I get this error message: "Script 'Target One Ally' line 78: NoMethodError occurred. undefined method 'one_no_user' for nil:NilClass'"

Line 78 is:
Code:
    return false if item.one_no_user && friends_unit.alive_members.size <= 1

I don't understand why this script is messing with my items. All it's supposed to do is make SKILLS that have the notetag '<one_ally_no_user>' make the user of the skill unselectable (so that my powerful healer can't self-heal). There's no reason it should be affecting the item command at all. I've tried tweaking that number but it made no difference and I didn't dare delete the line alltogether 'cause the whole script could fall apart for all I know, lol.

Anyone know how to fix this? I can't really afford to lose the script entirely since some of my character balances rely on it. Much appreciated for any help you can offer.

EDIT: Sorry! Forgot to add what other scripts I'm using!
- MOG_Battle_Hud_EX
- Yanfly Instant Cast
- MOG_Damage_Popup
- Yanfly Party System
- Yanfly Target Manager
- Minimum Damage Script (Don't Know Author)
When you want help with a script that you have, it needs to be in a script support forum, so...
Moved to: RGSSx Script Support
Replace the line with this:

Code:
return false if item.is_a?(RPG::Skill) && item.one_no_user && friends_unit.alive_members.size <= 1
Yeah, I forgot to account for empty skill/item lists. Fixed it on my pastebin.
The above fix works too, but it will disable this feature for the items completely. If you don't use this scope on the items, it's safe to use too.

But if possible, please just post a link to the script instead. the pastebin link will automatically show the whole code in a code-box thingy too.
Thanks everyone, it looks like everything's working now with the updated version of the script! ^_^ And sorry for not posting in the right place, I'll try to be mindful next time (hopefully there won't be one!)

EDIT: I don't know if anyone will see this but I didn't want to go against the 'no double posting' rule.

But Line 78 strikes again 🙁 I got this error once again after selecting Item in battle:
"Script 'Target One Ally' line 78 NoMethodError ocurred. undefined method 'one_no_user' for #<RPG::Weapon:0xa72ce50>"

No idea what triggered it 🙁 I'd played the game multiple times without an issue for ages and then this just kinda came out of nowhere.

EDIT 2: The new error also triggers whenever I scrolls to the weapons tab in the Item menu out of battle.

Original thread: https://forums.rpgmakerweb.com/threads/error-when-selecting-item.94482/