# How to get Player State reference in UI Widget Blueprint graph?

**URL:** <https://forums.unrealengine.com/t/how-to-get-player-state-reference-in-ui-widget-blueprint-graph/484073>\
**Category:** UI\
**Tags:** playerstate, unreal-engine, UI, Widget, Blueprint, question\
**Created:** [May 28, 2021, 9:06pm UTC](https://forums.unrealengine.com/t/how-to-get-player-state-reference-in-ui-widget-blueprint-graph/484073 "2021-05-28T21:06:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Didyeah](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Didyeah](https://forums.unrealengine.com/u/Didyeah)\
**Post date:** [May 28, 2021, 9:06pm UTC](https://forums.unrealengine.com/t/how-to-get-player-state-reference-in-ui-widget-blueprint-graph/484073/1 "2021-05-28T21:06:39Z")

</div>

I am trying to bind some of my HUD interface to the current player PlayerState variables but I can’t seem to find a way to get a reference to my custom PlayerState from the widget blueprint graph.  
It works just fine using character variables which I can get using GetPlayerCharacter but since I moved some of the variables to the PlayerState I need the PlayerState.  
Am I misunderstanding something? As far as I know the PlayerState is replicated and should be accessible locally.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [May 29, 2021, 8:16am UTC](https://forums.unrealengine.com/t/how-to-get-player-state-reference-in-ui-widget-blueprint-graph/484073/2 "2021-05-29T08:16:18Z")

</div>

How about this:

![340109-screenshot-2.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/f/f/6ff8ba6942672302517b52932e0ce5f0bca3352a.png)

---

<div class="post-metadata">

**Author:** ![Didyeah](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Didyeah](https://forums.unrealengine.com/u/Didyeah)\
**Post date:** [May 29, 2021, 1:03pm UTC](https://forums.unrealengine.com/t/how-to-get-player-state-reference-in-ui-widget-blueprint-graph/484073/3 "2021-05-29T13:03:02Z")

</div>

This is indeed how it should be done. This is what I was trying and it was failing but for some reason If I delay it by a fraction of a second it works just fine. I think it is because the widget constructor is executed before the player state is instantiated. It fixes my issue for now but doesn’t feel like a great fix.

![340110-capture.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/3/c/23ceeda1d065702975539911f84b7ff9516c5168.png)

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [May 29, 2021, 1:43pm UTC](https://forums.unrealengine.com/t/how-to-get-player-state-reference-in-ui-widget-blueprint-graph/484073/4 "2021-05-29T13:43:28Z")

</div>

It is not, but if it works…

---

<div class="post-metadata">

**Author:** ![lostburn](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@lostburn](https://forums.unrealengine.com/u/lostburn)\
**Post date:** [July 16, 2022, 2:48am UTC](https://forums.unrealengine.com/t/how-to-get-player-state-reference-in-ui-widget-blueprint-graph/484073/5 "2022-07-16T02:48:39Z")

</div>

I know this is kinda of old. But the player state, for what I tested, is loaded in a different order when you are the client vs server.  
Also, as you are trying to get the player state from the widget, depending on where you created your widget, that class can load before the player state (for example, if you are creating inside the player controller). In a blank project, I tested printing a string on both construction script and begin play, this is the order they were printed in the construction script:

Server : GameMode - Game State - Player Controller - Player State - Player Character  
Client (Server Version) : Player Controller - Player State - Player Character  
Client (Client Version) : Player Controller - Player Character - Game State - Player State

---

<div class="post-metadata">

**Author:** ![GatoDev](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/gatodev/32/719915_2.png) [@GatoDev](https://forums.unrealengine.com/u/GatoDev)\
**Post date:** [June 23, 2023, 8:39am UTC](https://forums.unrealengine.com/t/how-to-get-player-state-reference-in-ui-widget-blueprint-graph/484073/6 "2023-06-23T08:39:25Z")

</div>

Making this macro helped me. I’m not sure if this is 100% the way but it waits and loads the player state when avaliable.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/b/7/8b767eba758bb31c427054ddc8ccaa0949cfbe05.png)
