# Cast event when (Variable change)

**URL:** <https://forums.unrealengine.com/t/cast-event-when-variable-change/415961>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [January 30, 2018, 9:52pm UTC](https://forums.unrealengine.com/t/cast-event-when-variable-change/415961 "2018-01-30T21:52:25Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![Fortirus](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/fortirus/32/1104904_2.png) [@Fortirus](https://forums.unrealengine.com/u/Fortirus)\
**Post date:** [October 30, 2022, 9:56pm UTC](https://forums.unrealengine.com/t/cast-event-when-variable-change/415961/6 "2022-10-30T21:56:31Z")

</div>

For those who, like me, are faced with this task, I can recommend the following 💁‍♂️  
If you are developing a singleplayer game, you can use the **RepNotify** for Replication setting of the varible and use generated OnRep\_ function to call the event on the varible change.  
This method works in single mode [because](https://docs.unrealengine.com/5.0/en-US/networking-overview-for-unreal-engine/#networkmodesandservertypes)

> **Standalone** : The game is running as a server, that does not accept connections from remote clients. Any players participating in the game are strictly local players. This mode is used for single-player and local multiplayer games. It will run both server-side logic and client-side logic as appropriate for the local players.

However, for those who, like me, are working on a multiplayer project and want to do this only on the client and at the same time not overload the server and network - alas, I don’t have an exact way to solve this yet.  
Yes, you can create and use a “set function” instead of a just “Set”, but this option will only work when changing the values (calling the function) ​​​​in the blueprints, and not when the value of the variable is directly changed (like in maping).  
And of course, you can always use some C++ custom class and code, but we’re not here for that 🕶

So for now, I can only suggest a method that is used in the **Lyra project** - create a second variable that will be every tick/period of time, check if its value differs from the target one and when this happens - call the event and update this variable value.  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/2/b/f2b641f7c8190ec6da9e587a5b404419aabb2f30.png)

---

_[View the full topic](https://forums.unrealengine.com/t/cast-event-when-variable-change/415961)._
