# Weapon Variables Not Replicating When Weapon is Dropped

**URL:** <https://forums.unrealengine.com/t/weapon-variables-not-replicating-when-weapon-is-dropped/630440>\
**Category:** Multiplayer & Networking\
**Tags:** Replication, unreal-engine, Multiplayer, question, UE4-27, Blueprint\
**Created:** [August 17, 2022, 5:33pm UTC](https://forums.unrealengine.com/t/weapon-variables-not-replicating-when-weapon-is-dropped/630440 "2022-08-17T17:33:29Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![DynaZ\_II\_Spreeds](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/dynaz_ii_spreeds/32/561506_2.png) [@DynaZ\_II\_Spreeds](https://forums.unrealengine.com/u/DynaZ_II_Spreeds)\
**Post date:** [August 17, 2022, 5:33pm UTC](https://forums.unrealengine.com/t/weapon-variables-not-replicating-when-weapon-is-dropped/630440/1 "2022-08-17T17:33:29Z")

</div>

```auto
Hi there!
     I have been trying to figure out a replication problem. I am making an FPS and I want to drop a weapon and then store the stats into the dropped weapon on begin play. This is what it looks like.

```

**Drop:** (Spawns the actor of the equipped gun)

 ![1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/b/1/3b10a94b2c150bdb4ac68d10fa3c6ef5ed9d2577.jpeg)

**Store Values:** (This stores the values from my weapon base blueprint into the weapon being dropped)

 ![2](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/4/2/24284612470913807fdeb515cf521a8364f7de18.jpeg)

**Overlap Print:** (This prints the gun stats when my first person character overlaps)

 ![3](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/1/9/51915dc49688e8bbdf1f35e2702520f4e3aaa9db.jpeg)

 ![4](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/9/9/299ec78ab403e8105498b5f746c7fce37a7119ae.jpeg)

**Problem:**

```auto
     Say that the server shoots all the ammo in the magazine and then drops the weapon. The client can pick up the weapon and all the stats are perfectly fine:

```

**Server Shoot** (Server shoots all ammo in mag)

 ![5](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/7/1/171ff8432f63583d0d200734c8087859cd1955a8.jpeg)

**Client Pick Up**

 ![6](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/e/a/bea273ef0278b15fc399657afc42821b3aeeed63.jpeg)

```auto
     But now, let say that the client shoots all the ammo in the magazine and then drops the weapon. The server picks up a new gun and can't seem to read the variables that the client sets.

```

**Client Shoot** (Client shoots all ammo in mag)

 ![6](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/e/a/bea273ef0278b15fc399657afc42821b3aeeed63.jpeg)

**Server Pick Up**

 ![7](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/b/2/4b2e5b037d017536b48916cde8396507e8bfac25.jpeg)

```auto
     Here are the overlap print statements:

```

The Server Drops the Weapon and the Server Overlaps:  
 ![server drop print](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/8/f/a8f5dd6baddabfcb5703337af865159a6b9d91d3.jpeg)

The Server Drops the Weapon and the Client Overlaps:  
 ![client overlaps server](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/0/f/40f1458ef1129a837eddec880b143c7cf62908a2.jpeg)

The Client Drops the Weapon and the Client Overlaps:  
 ![client drop print](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/b/d/8bd474c5edfe4a8d1e984e4bca18a29b6c4c3260.jpeg)

The Client Drops the Weapon and the Server Overlaps: **NOTE: Issue**  
 ![server overlaps client](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/c/8/ec8d3e15c4e3fd97c205cc85ef12e8f53aa83d94.jpeg)

```auto
     I know that this is a lot to look through, but any help would be greatly appreciated. Thank you! 

```

---

<div class="post-metadata">

**Author:** ![DynaZ\_II\_Spreeds](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/dynaz_ii_spreeds/32/561506_2.png) [@DynaZ\_II\_Spreeds](https://forums.unrealengine.com/u/DynaZ_II_Spreeds)\
**Post date:** [August 20, 2022, 12:26am UTC](https://forums.unrealengine.com/t/weapon-variables-not-replicating-when-weapon-is-dropped/630440/2 "2022-08-20T00:26:08Z")

</div>

If you need anymore information to assist with the problem let me know!

---

<div class="post-metadata">

**Author:** ![Rev0verDrive](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rev0verdrive/32/907214_2.png) [@Rev0verDrive](https://forums.unrealengine.com/u/Rev0verDrive)\
**Post date:** [August 20, 2022, 1:13am UTC](https://forums.unrealengine.com/t/weapon-variables-not-replicating-when-weapon-is-dropped/630440/3 "2022-08-20T01:13:07Z")

</div>

On client drop you need to RPC the server the changes to the weapon. Otherwise ALL changes have to happen on the server in the first place.

Server spawns weapon, Actor replicates. Client overlaps to pick up, RPC’s server. Server checks overlap and attaches to client character.

Character fires, RPC’s server to shoot. Server shoots and deducts ammo, rep\_notifies the ammo count back to client.

Client drops weapon, RPC’s server to drop. Server detaches, drops.

---

<div class="post-metadata">

**Author:** ![DynaZ\_II\_Spreeds](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/dynaz_ii_spreeds/32/561506_2.png) [@DynaZ\_II\_Spreeds](https://forums.unrealengine.com/u/DynaZ_II_Spreeds)\
**Post date:** [August 20, 2022, 5:30am UTC](https://forums.unrealengine.com/t/weapon-variables-not-replicating-when-weapon-is-dropped/630440/5 "2022-08-20T05:30:23Z")

</div>

Sorry I am still learning replication. So when you say that I need to RPC the server changes to the weapon, would that require a run on server inside the weapon blueprint?

---

<div class="post-metadata">

**Author:** ![Rev0verDrive](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rev0verdrive/32/907214_2.png) [@Rev0verDrive](https://forums.unrealengine.com/u/Rev0verDrive)\
**Post date:** [August 20, 2022, 7:33am UTC](https://forums.unrealengine.com/t/weapon-variables-not-replicating-when-weapon-is-dropped/630440/6 "2022-08-20T07:33:28Z")

</div>

Yes, but from Character or Controller.

Input pressed → switch has authority: remote → RPC (Run on Server)

Server (RPC): switch has authority: Auth → Make change/Fire Weapon/etc etc

---

<div class="post-metadata">

**Author:** ![DynaZ\_II\_Spreeds](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/dynaz_ii_spreeds/32/561506_2.png) [@DynaZ\_II\_Spreeds](https://forums.unrealengine.com/u/DynaZ_II_Spreeds)\
**Post date:** [August 20, 2022, 8:38pm UTC](https://forums.unrealengine.com/t/weapon-variables-not-replicating-when-weapon-is-dropped/630440/7 "2022-08-20T20:38:08Z")

</div>

So does this only work on input from a character/controller? Not a begin play?

---

<div class="post-metadata">

**Author:** ![Rev0verDrive](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rev0verdrive/32/907214_2.png) [@Rev0verDrive](https://forums.unrealengine.com/u/Rev0verDrive)\
**Post date:** [August 20, 2022, 10:00pm UTC](https://forums.unrealengine.com/t/weapon-variables-not-replicating-when-weapon-is-dropped/630440/8 "2022-08-20T22:00:03Z")

</div>

You can do begin play → switch has auth → whatever.

Yet this action should be run on the server at creation. Client shouldn’t be doing anything “begin play” on replicated actors.

---

<div class="post-metadata">

**Author:** ![DynaZ\_II\_Spreeds](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/dynaz_ii_spreeds/32/561506_2.png) [@DynaZ\_II\_Spreeds](https://forums.unrealengine.com/u/DynaZ_II_Spreeds)\
**Post date:** [August 21, 2022, 4:54pm UTC](https://forums.unrealengine.com/t/weapon-variables-not-replicating-when-weapon-is-dropped/630440/9 "2022-08-21T16:54:06Z")

</div>

So if the weapon actor itself is spawning on server, will the begin play trigger on server?

---

<div class="post-metadata">

**Author:** ![Rev0verDrive](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rev0verdrive/32/907214_2.png) [@Rev0verDrive](https://forums.unrealengine.com/u/Rev0verDrive)\
**Post date:** [August 21, 2022, 7:17pm UTC](https://forums.unrealengine.com/t/weapon-variables-not-replicating-when-weapon-is-dropped/630440/10 "2022-08-21T19:17:10Z")

</div>

yup, but you need to ensure it only executes on the server.

---

<div class="post-metadata">

**Author:** ![DynaZ\_II\_Spreeds](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/dynaz_ii_spreeds/32/561506_2.png) [@DynaZ\_II\_Spreeds](https://forums.unrealengine.com/u/DynaZ_II_Spreeds)\
**Post date:** [August 21, 2022, 9:06pm UTC](https://forums.unrealengine.com/t/weapon-variables-not-replicating-when-weapon-is-dropped/630440/11 "2022-08-21T21:06:12Z")

</div>

Ok! I will try to mess with it a bit. Thanks.

---

<div class="post-metadata">

**Author:** ![Rev0verDrive](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rev0verdrive/32/907214_2.png) [@Rev0verDrive](https://forums.unrealengine.com/u/Rev0verDrive)\
**Post date:** [August 21, 2022, 10:56pm UTC](https://forums.unrealengine.com/t/weapon-variables-not-replicating-when-weapon-is-dropped/630440/12 "2022-08-21T22:56:11Z")

</div>

If your begin play changes aren’t applying to the client end, then you may want to disable replication by default and enable after begin play changes apply.

This is the only hitch I can recall happening. Other work around is to rep on default and multicast or rep\_notify the begin play changes as needed. Downside here is multiple uses of the network and delays on the client with changes.

---

<div class="post-metadata">

**Author:** ![DynaZ\_II\_Spreeds](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/dynaz_ii_spreeds/32/561506_2.png) [@DynaZ\_II\_Spreeds](https://forums.unrealengine.com/u/DynaZ_II_Spreeds)\
**Post date:** [August 22, 2022, 3:56pm UTC](https://forums.unrealengine.com/t/weapon-variables-not-replicating-when-weapon-is-dropped/630440/13 "2022-08-22T15:56:48Z")

</div>

Can you explain how I would do that? Would I just uncheck replicates in the actor settings?

---

<div class="post-metadata">

**Author:** ![DynaZ\_II\_Spreeds](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/dynaz_ii_spreeds/32/561506_2.png) [@DynaZ\_II\_Spreeds](https://forums.unrealengine.com/u/DynaZ_II_Spreeds)\
**Post date:** [August 22, 2022, 4:08pm UTC](https://forums.unrealengine.com/t/weapon-variables-not-replicating-when-weapon-is-dropped/630440/14 "2022-08-22T16:08:11Z")

</div>

I am not sure if the problem is the begin play. When I try to store the clients weapon variables into the weapon pickup they do not show to the server. Basically, I cast to my FPS character then I cast to the weapon and then grab each variable (fire rate, ammo, etc.) and store them into the weapon pickup on begin play. I just cant seem to figure out the client side.

---

<div class="post-metadata">

**Author:** ![Rev0verDrive](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rev0verdrive/32/907214_2.png) [@Rev0verDrive](https://forums.unrealengine.com/u/Rev0verDrive)\
**Post date:** [August 22, 2022, 10:40pm UTC](https://forums.unrealengine.com/t/weapon-variables-not-replicating-when-weapon-is-dropped/630440/15 "2022-08-22T22:40:57Z")

</div>

There’s 2 copies of the actor. One is on the server (Authoritative) and one on your client sim (Simulated).

When your client changes values on its copy it isn’t changing them on the server. It’s only changing local data.

If the client makes direct changes it has to UPDATE the server via either REP\_Notify or RPC (run on server).

The Best Approach as noted previously is to RPC the server to make the change and have it Replicate those changes to clients.

My personal approach to weapon configs is to use a data table to set the variables at creation.

Server Spawns it. In construction it reads the table, and sets values in a struct.

When an action occurs that can change the values it’s done on the server not the client.

---

<div class="post-metadata">

**Author:** ![Rev0verDrive](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rev0verdrive/32/907214_2.png) [@Rev0verDrive](https://forums.unrealengine.com/u/Rev0verDrive)\
**Post date:** [August 26, 2022, 5:48am UTC](https://forums.unrealengine.com/t/weapon-variables-not-replicating-when-weapon-is-dropped/630440/16 "2022-08-26T05:48:29Z")

</div>

Just checking in… You figure it out?

---

<div class="post-metadata">

**Author:** ![UnrealSolver](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/unrealsolver/32/1194693_2.png) [@UnrealSolver](https://forums.unrealengine.com/u/UnrealSolver)\
**Post date:** [August 26, 2022, 6:56am UTC](https://forums.unrealengine.com/t/weapon-variables-not-replicating-when-weapon-is-dropped/630440/17 "2022-08-26T06:56:27Z")

</div>

Just checked in as I am learning MP too and thanks Broski for your support, it’s clear and nice written \<3

---

<div class="post-metadata">

**Author:** ![DynaZ\_II\_Spreeds](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/dynaz_ii_spreeds/32/561506_2.png) [@DynaZ\_II\_Spreeds](https://forums.unrealengine.com/u/DynaZ_II_Spreeds)\
**Post date:** [August 26, 2022, 12:01pm UTC](https://forums.unrealengine.com/t/weapon-variables-not-replicating-when-weapon-is-dropped/630440/18 "2022-08-26T12:01:19Z")

</div>

Thanks for checking! I’m still struggling. I’m just trying to troubleshoot with print strings. I have the server spawning the weapon and I have the client variables updating with a run on server but it is still the same. I thought of trying a data table like you said but I haven’t found any videos explaining how to do that with weapon dropping.

---

<div class="post-metadata">

**Author:** ![Rev0verDrive](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rev0verdrive/32/907214_2.png) [@Rev0verDrive](https://forums.unrealengine.com/u/Rev0verDrive)\
**Post date:** [August 26, 2022, 8:38pm UTC](https://forums.unrealengine.com/t/weapon-variables-not-replicating-when-weapon-is-dropped/630440/19 "2022-08-26T20:38:17Z")

</div>

I’m slammed with work today, but I’ll whip up a demo this weekend.

---

<div class="post-metadata">

**Author:** ![DynaZ\_II\_Spreeds](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/dynaz_ii_spreeds/32/561506_2.png) [@DynaZ\_II\_Spreeds](https://forums.unrealengine.com/u/DynaZ_II_Spreeds)\
**Post date:** [August 26, 2022, 11:25pm UTC](https://forums.unrealengine.com/t/weapon-variables-not-replicating-when-weapon-is-dropped/630440/20 "2022-08-26T23:25:42Z")

</div>

Wow that would be amazing! Thank you!
