Attaching object to component with Replication

To best ask the question I am going to describe what I want to do. If a player picks up an item from the ground, goes to his/her inventory system and equip it to the first slot, I want that mesh to attach to the player’s hand. I have got it working all the way for the server and it works fine. If I am playing as the server as soon as I attach the item I can see it attach to the players hand on the client side. However, when I play as a client it doesn’t work.

The way I am doing it(and there is probably an easier way) is that in the pawn that I am controlling has a function that runs on server and has parameter of the pawn that is requesting and the object. I did some debugging and I found out that once the object get to the server function it is lost unless I am playing as the server.

Any advice would be greatly praised.

Do you call attach on client side also ? Cause item if it not replicated client will never know, and also depend on what component replicated on item, so something like attach parent is never replicated.
For you case you can call attach on your local, then tell server to attach, then server need to tell all other client to attach item also.

Thanks for the response. Right now I created a custom function in blueprints that ‘runs on server.’ The problem is that if the client call that function it loses the the object that should be attached to the the player’s hand.

What I did to fix it was made a spawn actor and pass it the class of the object I wanted to spawn. Then I attached new newly spawn object to the character.