The nicknaming special determines which Pokemon you're nicknaming by the value in variable 0x8004. A value of 0x0 indicates that you're nicknaming the first Pokemon, 0x1 is the second etc. Now the game starts out with 0x8004 set to 0x0 by default, but turning on the PC in the player's room (not even taking out the item), 0x8004 is set to 0x1 as an argument for the PC special. So if you interact with the PC, 0x8004 is no longer set to 0x0, leaving the nicknaming special to try and nickname the second Pokemon in your party which doesn't exist, leading to the error you're receiving. To fix this, edit your script to include the command 'setvar 0x8004 0x0' before the nicknaming special and everything should work perfectly.