Download

Engine Being Random And Dumb (Video)

https://youtube.com/watch?v=CwnZpjrN14E

STEPS: What SHOULD happen

1: player character selects the pawn to cast to

2: Player character casts “PickupWeapon” to the selected pawn

3: Selected pawn Attaches itself to the camera component of the Player character

3: ???Profit -(not an actual step)

At 00:31, connect LookAtObject left of your CastTo nodes to itself.
Remember, data lines(colored lines) should better be from with in the same part of execution lines(white), your style of connection will confuse blueprint compiler and make it thinks extra hard.
(And probably why it’s random, because you tap multiple times, the function is returned multiple times, which another execution line[my guess is OnTick], trying to see if it’s possible to cast a data input that comes from no where.)

Also, check my answer hub questions that shows you how to properly do trace and validate and save your reference.
And, you should really make the whole process(trace and pick up) with in one event.

Most likely your line trace is missing the collision box. Put a print string on the the Hit Actor from your Line Trace so you can see if it is even returning a hit on the times that it fails.

If the line trace is the problem you could change to a small sphere trace to give more room for error, or work on the collision box of the gun.

Turns out it wasn’t random at all

https://youtube.com/watch?v=2lnGui_x3T8