# Game instance not working

**URL:** <https://forums.unrealengine.com/t/game-instance-not-working/364904>\
**Category:** Editor Scripting\
**Tags:** savegame, casting, game-instance, open-level, unreal-engine, Blueprint, question\
**Created:** [July 23, 2016, 3:01pm UTC](https://forums.unrealengine.com/t/game-instance-not-working/364904 "2016-07-23T15:01:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dogu189](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@dogu189](https://forums.unrealengine.com/u/dogu189)\
**Post date:** [July 23, 2016, 3:01pm UTC](https://forums.unrealengine.com/t/game-instance-not-working/364904/1 "2016-07-23T15:01:55Z")

</div>

Hey I created an game instance called “DefGameIns”  
And in FirstpersonCharacter\_BP here is what I have:

![99720-capture.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/c/1/ac1c9e2914ed12e3b01b67bf56187dca9d15962c.png)

I press L to make lagamcheck true and press H it says ‘true’ I press z to open another level and press h it says false.  
I made sure my variables were public and selected the DefGameIns as game instance in the project settings  
I really dont know what its causing it

Please help as soon as possible I can’t really continue on with my project.

---

<div class="post-metadata">

**Author:** ![Kibblesticks](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Kibblesticks](https://forums.unrealengine.com/u/Kibblesticks)\
**Post date:** [July 23, 2016, 4:00pm UTC](https://forums.unrealengine.com/t/game-instance-not-working/364904/2 "2016-07-23T16:00:58Z")

</div>

When you open another level your pawn’s variables are cleared and the pawn is reloaded. You need to save the variable to disk then retrieve it when the pawn loads.  
[https://docs.unrealengine.com/latest/INT/Gameplay/SaveGame/Blueprints/index.html](https://docs.unrealengine.com/latest/INT/Gameplay/SaveGame/Blueprints/index.html)

Alternatively you _might_ be able to save it to a HUD class (and assign that HUD in the gamemode), but I think a HUD will reset on level change too and you’ll have the same issue.

---

<div class="post-metadata">

**Author:** ![dogu189](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@dogu189](https://forums.unrealengine.com/u/dogu189)\
**Post date:** [July 23, 2016, 4:20pm UTC](https://forums.unrealengine.com/t/game-instance-not-working/364904/3 "2016-07-23T16:20:35Z")

</div>

Yeah I know it clears the pawn variables but game instances are for that, But mine doesnt seem to be working

---

<div class="post-metadata">

**Author:** ![dogu189](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@dogu189](https://forums.unrealengine.com/u/dogu189)\
**Post date:** [July 23, 2016, 5:47pm UTC](https://forums.unrealengine.com/t/game-instance-not-working/364904/4 "2016-07-23T17:47:51Z")

</div>

Ok I found the Fix if anyone  
the problem was When i pressed L it was actually loading it to the instance  
But when i pressed H it was printing the old state of the instance instead of the current  
so the fix was , before I print string I had to cast again to load the current instance to the pawn and feed the print string

---

<div class="post-metadata">

**Author:** ![Kibblesticks](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Kibblesticks](https://forums.unrealengine.com/u/Kibblesticks)\
**Post date:** [July 23, 2016, 6:14pm UTC](https://forums.unrealengine.com/t/game-instance-not-working/364904/5 "2016-07-23T18:14:09Z")

</div>

Ah sorry I didn’t realise that was what a game instance was, glad you fixed it.
