# How do I save and load when AI's behavior tree changes?

**URL:** <https://forums.unrealengine.com/t/how-do-i-save-and-load-when-ais-behavior-tree-changes/488026>\
**Category:** Editor Scripting\
**Tags:** savegame, Behavior-Tree, load-game, unreal-engine, question\
**Created:** [August 26, 2021, 9:26am UTC](https://forums.unrealengine.com/t/how-do-i-save-and-load-when-ais-behavior-tree-changes/488026 "2021-08-26T09:26:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![GoldenPixy](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/goldenpixy/32/924788_2.png) [@GoldenPixy](https://forums.unrealengine.com/u/GoldenPixy)\
**Post date:** [August 26, 2021, 9:26am UTC](https://forums.unrealengine.com/t/how-do-i-save-and-load-when-ais-behavior-tree-changes/488026/1 "2021-08-26T09:26:07Z")

</div>

Hi, there. I have an AI with several behavior trees. The player should use some currency so the AI can use the next behavior tree. How can I save the game each time the AI starts using the next behavior tree then load the game exactly after the AI started to use the latest behavior tree?

---

<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:** [August 26, 2021, 10:12am UTC](https://forums.unrealengine.com/t/how-do-i-save-and-load-when-ais-behavior-tree-changes/488026/2 "2021-08-26T10:12:43Z")

</div>

You need to use the save game.

Put a variable in the save game which is of type ‘behavior tree object reference’. When the AI controller starts, it looks in the save game to see which BT it needs to load:

 ![347375-screenshot-1.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/2/9/829014647780037c275af11d67f479ccff5ba797.jpeg)
