Script Error [Undefined Method for NilClass]

I've had a lot of luck so far with all the wonderful scripts people have posted on here, but I'm getting an error with the latest one.

The script I'm using is PK8's Change Character Opacity script, and the error I'm getting is this:

[IMG]http://img6.imageshack.us/img6/3350/m1jx.png[/IMG]

Any ideas how to go about fixing this? :/

Here's PK8's script, exactly as I copied it (and I pasted it below Materials above Main, like the other scripts I'm using):

Spoiler
Code:
=beginChange Character Opacity in Frames 2.1.1by PK8Created: 5/12/2009Modified: 6/11/2012──────────────────────────────────────────────────────────────────────────────■ IntroductionThis allows game creators to change the opacity of character sprites to acertain amount in a set number of frames.──────────────────────────────────────────────────────────────────────────────■ FeaturesChange the opacity of a character's sprite in a certain number of frameswith a script call.──────────────────────────────────────────────────────────────────────────────■ UsageScript call for changing the player's sprite opacity:$game_player.opacity_change(opacity, duration, relative)Script call for changing an event's sprite opacity:$game_map.events[id].opacity_change(opacity, duration, relative)Script call for changing a vehicle's sprite opacity:$game_map.vehicle[id].opacity_change(opacity, duration, relative)* 0: Boat, 1: Ship, 2: AirshipScript call for changing a follower's sprite opacity:$game_player.followers[id].opacity_change(opacity, duration, relative)* Starts with 0.opacity: Min: 0, Max: 255duration: Min: 0relative: true or false (Optional. Defaults to false)──────────────────────────────────────────────────────────────────────────────■ ExamplesThis would lower the player's sprite opacity by 20 in 20 frames$game_player.opacity_change(-20, 20, true)This would raise the player's sprite opacity back up by 20 in 20 frames$game_player.opacity_change(20, 20, true)──────────────────────────────────────────────────────────────────────────────■ What's New? (MM/DD/YYYY)v1 (05/12/2009): Initial releasev2 (04/11/2012): Recoded.v2.1 (04/15/2012): Adds new relative argument to opacity_changev2.1.1 (06/11/2012): Shortened the code, made @opacity, @opacity_target, and@opacity_duration accessible via script call, andimproved the documentation.──────────────────────────────────────────────────────────────────────────────■ Methods Aliasedo Game_CharacterBase.init_public_memberso Game_CharacterBase.update=end#==============================================================================# ** Game_CharacterBase#------------------------------------------------------------------------------# This base class handles characters. It retains basic information, such as# coordinates and graphics, shared by all characters.#==============================================================================class Game_CharacterBase#---------------------------------------------------------------------------# * Alias Listings#---------------------------------------------------------------------------unless method_defined?(:pk8_cco_init_public_members)alias_method(:pk8_cco_init_public_members, :init_public_members)alias_method(:pk8_cco_update, :update)end#--------------------------------------------------------------------------# * Initialize Public Member Variables#--------------------------------------------------------------------------def init_public_memberspk8_cco_init_public_members@opacity_target, @opacity_duration = 0, 0end#--------------------------------------------------------------------------# * Opacity Change# opacity : Target opacity. (0 - 255)# duration : Frame amount.# relative : References current value and adds to it, if true.#--------------------------------------------------------------------------def opacity_change(opacity, duration, relative = false)@opacity_target = (relative == true ? @opacity + opacity : opacity)@opacity_duration = duration@opacity = @opacity_target.clone if @opacity_duration == 0end#--------------------------------------------------------------------------# * Frame Update#--------------------------------------------------------------------------def updatepk8_cco_updateif @opacity_duration >= 1d = @opacity_duration@opacity = (@opacity * (d - 1) + @opacity_target) / d@opacity_duration -= 1endendend
I need more information to try and recreate the problem.

Whose/what's opacity are you trying to change?
Well there's only the one line that it could be:

Code:
if @opacity_duration >= 1
Try using:
Code:
if @opacity_duration && @opacity_duration >= 1
Never mind, sorry. I'm an idiot.

I was loading up a saved game after having added the new script, and that's why it was giving me the error.

Sorry for wasting your time, and thanks for trying to help.
Ay. Small mistakes are too easy to make. Have fun with your game!
Was going to suggest it might have been because of a saved game prior to adding the script 🙂


I've moved this thread to RGSSx Script Support. Please be sure to post your threads in the correct forum next time. Thank you.


This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/script-error-undefined-method-for-nilclass.20894/