[XP] Error: undefined method `[]=' for 0:Fixnum

I have the following code snippet that seems to cause problems

Code:
def check_daily_tasks
      cooked       = $game_variables[29]
      cooked_miss  = $game_variables[28]
      cleaned      = $game_variables[31]
      cleaned_miss = $game_variables[30]
      cooked_miss  += 2 - cooked
      cleaned_miss += 1 - cleaned
      $game_variables[28] = cooked_miss
      $game_variables[30] = cleaned_miss
      $game_variables[29] = 0
      $game_variables[31] = 0
  end

Everytime it gets called I get the follwoing error:


"Script 'Time' line 49: NoMethodError occured. undefined method `[]=' for 0:Fixnum"


Line 49 is this one:

Code:
$game_variables[28] = cooked_miss

I'm not using any other scripts. All the variables are local variables that are declared in that method. There must be some kind of Syntax error that I don't understand. Can anybody help me figure out what is going wrong here?


Edit: Nevermind, I found my mistake. I accidentally set the whole $game_variables array to 0 in the method from which I was calling the above method, because I forgot the square brackets. Thread can be locked, or marked as solved, or whatever happens in this forum when things get resolved.

Original thread: https://forums.rpgmakerweb.com/threads/xp-error-undefined-method-for-0-fixnum.59578/