Accessed none trying to read property

Hi, I am running into the same error again and again and I can’t find a solution.
I am reproducing this tutorial : UE4 Tutorial: How to setup weapon swapping - YouTube

Here are the screenshots of the different blueprint entries :

][2]

124056-untitled-3.jpg

I have two weapon blueprints that I use for this test, I placed them on the scene and the pickup part is fine.
The first issue is that I can’t unload the weapon from the socket and I get this message error :
Error Blueprint Runtime Error: Accessed None trying to read property CurrentWeapon from function: ‘DropCurrentWeapon’ from node: DetachActorFromActor (Deprecated) in graph: DropCurrentWeapon in object: Player with description: Accessed None trying to read property CurrentWeapon

But the variable CurrentWeapon is used and works elsewhere, I don’t understand why it is not working in the DropCurrentWeapon function, when it is working in the tutorial.

I think you want to Set the Variable of Current Weapon to new one after dropping the current.

In the second image after the attach is done you set the Current Weapon to None (eg you don’t input any data so it will be set to None). Try instead hook up the output (As Weapon) of the Cast To Weapon (which is the Weapon you hit with your trace) to the Input of Set Current Weapon after the AttachActorToComponent.

Thanks a lot for this answer, it solved the weapon still attached to socket issue. That’s great.
I still have a report of the “Accessed none” issue, but just once. May be it occurs at the beginning of the play sequence, probably because before I click on any pick ups, there is no weapon loaded and the value is actually none. Well that’s my guess…

Yeah, it is none the first time, because you do the Drop Weapon event but dont have a weapon in your hand. To get rid of the fail message you can use the
“Is Valid?” check inside the Drop Weapon function. The IsValid? checks if it’s None and don’t continue if its

Thanks a lot sir.

Glad I could help!

If it solves the problem don’t forget to mark my answer as Solved for others with similar questions can see.