Accessed none trying to read

Hi , I am person utterly lost with blueprints and are more suited to 3D modeling. That said I am finishing up a tiny project for class and have no teacher to help with this. Right now all I am trying to do is have the character pick up a few notes, have that then store a number and when this number is reached the bookcase shall move. Sounds simple but every time I try making the condition for the 5 notes I end up with the “Accessed none trying to read error”

I know my blueprints are janky as hell but if it works, it works. I have a tiny understanding on what to do with most just being an amalgamation of tutorials for different things mashed together. I think i understand that the problem is the branch’s reference is bad but I have no clue as to why as it worked on my door blueprints just fine.

If anyone has some sort of clue to how to fix it I would greatly appreciate it.

You are destroying your note actor after incrementing the variable. You need to not destroy it.

theres a few issues that i can see here, first having a timeline on tick is probably a bad idea, second your setting a variable in an actor then destroying that actor which makes no sense. im assuming that the picture with the left mouse button event is the note bp right? below is how i would modify your script to get it to work.

ok now to get your script to work first we need be storing the number of notes variable in a place where the actor wont be destroyed. A good place for storing the variable is the character (this depends on your game but for now lets go with character). to do this open your character blueprint and add the variable notes in. then open your notes bp and instead of having the variable in the notes we are going to access the notes variable located in the character. we do this by using the get player character node then casting that to the class of the character (in my example the character was a thirdpersoncharcter), then we drag off the as (insert class here) and search for our notes variable, then all thats left is to increment the variable which is a shorthand way of taking the variable adding 1 then setting it. This part is shown in picture 2.

next comes the bookcase script which is similar to what you already have except we need to get the variable again from the character. i split this into two sections to make it a little bit lighter on tick. so on begin play we get a reference to the character, cast to its class, then save this reference as a variable (you want this variable to be of the type of the character class so right click the as thirdpersoncharacter pin and say promote to variable) so we can access it later and not have to cast everytime. next on tick get the character reference variable then drag off of it and get the notes variable, then just compare that value to the desired number of notes (i made this a variable for easy tweaking). next is where we tackle the other problem of the timeline on tick. we really only want the timeline to fire once and not on every frame so to create this limit we use the do once node. then for the sake of keeping things clean and organized i used a custom event which actually opens the bookcase via the timeline.

im sure there are probably better ways to accomplish all this but i wanted to keep it similar to what you have, but just clean it up a bit and make it work a bit better. if you have any questions let me know and ill see what i can do to help good luck.

Oh I am such an idiot… how did I not see I was destroying the actor and not the component.
I guess it just took a fresh pair of eyes.

Thanks :slight_smile:

■■■■ thank you for taking your time to do this. Never expected for someone to go out of their way to create this. I really appreciate it and will take on board the information you have given me.
Thanks.