# How to execute ONCE and FOR ALL ?

**URL:** <https://forums.unrealengine.com/t/how-to-execute-once-and-for-all/468430>\
**Category:** Community & Industry Discussion\
**Tags:** launch, loading, unreal-engine, question\
**Created:** [July 20, 2020, 11:12pm UTC](https://forums.unrealengine.com/t/how-to-execute-once-and-for-all/468430 "2020-07-20T23:12:38Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![UraniumBonBeurre](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@UraniumBonBeurre](https://forums.unrealengine.com/u/UraniumBonBeurre)\
**Post date:** [July 20, 2020, 11:12pm UTC](https://forums.unrealengine.com/t/how-to-execute-once-and-for-all/468430/1 "2020-07-20T23:12:38Z")

</div>

Hi guys, I want my game to load settings just once and for all ONLY when the player launch the game. Therefore DO ONCE functions are not working in this case… How do I do that?

---

<div class="post-metadata">

**Author:** ![Tuerer](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/tuerer/32/1008648_2.png) [@Tuerer](https://forums.unrealengine.com/u/Tuerer)\
**Post date:** [July 20, 2020, 11:18pm UTC](https://forums.unrealengine.com/t/how-to-execute-once-and-for-all/468430/2 "2020-07-20T23:18:49Z")

</div>

Add a bool “Are Setting Loaded” into the Game Instance and change to True it after the settings are loaded. If the bool is True, don’t load settings.

---

<div class="post-metadata">

**Author:** ![UraniumBonBeurre](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@UraniumBonBeurre](https://forums.unrealengine.com/u/UraniumBonBeurre)\
**Post date:** [July 20, 2020, 11:33pm UTC](https://forums.unrealengine.com/t/how-to-execute-once-and-for-all/468430/3 "2020-07-20T23:33:33Z")

</div>

I didn’t do this, as I only use SaveGame and GameInstance stuff, instead of “Are Setting Loaded”, but I’ll still try this 😉

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [July 21, 2020, 7:16am UTC](https://forums.unrealengine.com/t/how-to-execute-once-and-for-all/468430/4 "2020-07-21T07:16:37Z")

</div>

Like Tuerer said, except you need to store it in the save game, to make sure it never runs again.

---

<div class="post-metadata">

**Author:** ![UraniumBonBeurre](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@UraniumBonBeurre](https://forums.unrealengine.com/u/UraniumBonBeurre)\
**Post date:** [July 21, 2020, 11:53am UTC](https://forums.unrealengine.com/t/how-to-execute-once-and-for-all/468430/5 "2020-07-21T11:53:01Z")

</div>

I did something and it works fine ! No need to call SaveGames actually, I just put at the beginning of my game a cast to my game instance and I get the ONCE\_Enabled. Then, as my gameinstance isn’t load yet, the return value of that variable is false (its default value). If it’s false, it executes a load, and at the end it put ONCE\_Enabled on true. And if it’s true, it executes nothing. In fact, all is working thanks to the default value of my variable 😉 Thanks !

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [July 21, 2020, 12:27pm UTC](https://forums.unrealengine.com/t/how-to-execute-once-and-for-all/468430/6 "2020-07-21T12:27:37Z")

</div>

If you quit the game and restart, it will run again…

---

<div class="post-metadata">

**Author:** ![UraniumBonBeurre](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@UraniumBonBeurre](https://forums.unrealengine.com/u/UraniumBonBeurre)\
**Post date:** [July 21, 2020, 1:35pm UTC](https://forums.unrealengine.com/t/how-to-execute-once-and-for-all/468430/7 "2020-07-21T13:35:50Z")

</div>

Yes, but just one time. Oh I see you thought it was once time for all in your life, yeah I was not precise enough.

---

<div class="post-metadata">

**Author:** ![AngeIV](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AngeIV](https://forums.unrealengine.com/u/AngeIV)\
**Post date:** [July 22, 2020, 10:06am UTC](https://forums.unrealengine.com/t/how-to-execute-once-and-for-all/468430/8 "2020-07-22T10:06:35Z")

</div>

This is a function the GAME MODE class should take care of.  
Either if your game is single player or multiplayer.  
In game mode you have a lot of functions to overwrite, including on player pawn spawned. And it triggers once - allowing you to run logic with authority on the pawn or controller directly. in example - fill inventory from savegame.

---

<div class="post-metadata">

**Author:** ![ElBunDisMan](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ElBunDisMan](https://forums.unrealengine.com/u/ElBunDisMan)\
**Post date:** [May 29, 2024, 4:29pm UTC](https://forums.unrealengine.com/t/how-to-execute-once-and-for-all/468430/9 "2024-05-29T16:29:44Z")

</div>

In my case worked , if I duplicate a level and create a variable level name, where it works as once setting that overrides the variable on the level name to LevelName\*Duplicate without setting … and then it always loads the second level, which is the same, just without the once function.
