ScriptName xxxScript ; attach this script to the book - preferably xxx is the name of the bookShort countBegin onactivate Activate If (count == 0 ) ; did I already do this? Set count to 1 Player.AddItem yyyKey 1 : yyyKey is the formid of the key EndifEnd
No need for any ref variables and the count is how many times you gave the player the key - which you want to stop at 1! - not the number to give this time. Note that the "Activate" is outside the if, because you always want to do this. Giving the key is inside a test to see if you already gave it.
The position of the Activate before or after the if is not important here, but if you added a SetStage to update the Journal when the player gets the key, then the order of the commands becomes more important, as you may want one thing to display on top of the other.