# Float variable keeps resetting to its default value

**URL:** <https://forums.unrealengine.com/t/float-variable-keeps-resetting-to-its-default-value/447951>\
**Category:** Blueprint\
**Tags:** unreal-engine, question, Blueprint, set-timer\
**Created:** [April 27, 2019, 1:50am UTC](https://forums.unrealengine.com/t/float-variable-keeps-resetting-to-its-default-value/447951 "2019-04-27T01:50:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![SithHunter](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SithHunter](https://forums.unrealengine.com/u/SithHunter)\
**Post date:** [April 27, 2019, 1:50am UTC](https://forums.unrealengine.com/t/float-variable-keeps-resetting-to-its-default-value/447951/1 "2019-04-27T01:50:28Z")

</div>

Edit: Changed the title to be more accurate as to what the problem is.

Hey everybody.

I’ve been trying to resolve an issue for the better part of a day now and the behavior isn’t making any sense to me.

I have a round based FPS where the player has to take out a number of enemies to advance to the next level. In order to scale up the challenge, each level increases that goal value, and every few rounds (Specified in a variable as a fixed value), the spawn timer for enemies will decrease by 2 seconds until it eventually reaches a minimum value of 2 seconds.

What is happening is that the first few rounds work perfectly; but when the round is reached at which the timer should decrease, it appears to work. The following rounds though will revert this value to the original timer value.

I’m doing the check against whether to decrease the timer using a modulo - Current Round % “Variable at which the decrease should happen” == 0 on a branch. If it is true, the timer is decreased by 2 and then put into a MAX comparison to make sure the value never goes below 2 seconds and then the timer value is set to this new number.

I have no clue why this is happening. It seems that the original timer value is being reapplied to the variable timer value any time the branch is false…

 ![275325-timer.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/6/a/66a37dfcf1f69f6597d972cbf79977a294a45c7f.png)

Any help with this would be greatly appreciated because I’m about ready to give up and just use an array with the timer values for the first 100 rounds.

---

<div class="post-metadata">

**Author:** ![Imagine-Games](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Imagine-Games](https://forums.unrealengine.com/u/Imagine-Games)\
**Post date:** [April 27, 2019, 4:17am UTC](https://forums.unrealengine.com/t/float-variable-keeps-resetting-to-its-default-value/447951/2 "2019-04-27T04:17:57Z")

</div>

maybe not the answer you are looking for but, have you tried print stringing all the values, 1 by 1 to make sure they are how you want them to be…?

---

<div class="post-metadata">

**Author:** ![Kmontoya](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Kmontoya](https://forums.unrealengine.com/u/Kmontoya)\
**Post date:** [April 28, 2019, 12:02am UTC](https://forums.unrealengine.com/t/float-variable-keeps-resetting-to-its-default-value/447951/3 "2019-04-28T00:02:57Z")

</div>

I’ve ran into some weird float variable behaviors recently, and was only able to fix it by deleted the variable(s), compiling the BP, and then re-create the variable with a different name…

Maybe worth a try if haven’t yet…

---

<div class="post-metadata">

**Author:** ![SithHunter](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SithHunter](https://forums.unrealengine.com/u/SithHunter)\
**Post date:** [April 28, 2019, 11:33pm UTC](https://forums.unrealengine.com/t/float-variable-keeps-resetting-to-its-default-value/447951/4 "2019-04-28T23:33:04Z")

</div>

I gave that a try but no luck. Thanks for the idea though.

---

<div class="post-metadata">

**Author:** ![love.society](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/love.society/32/620127_2.png) [@love.society](https://forums.unrealengine.com/u/love.society)\
**Post date:** [February 7, 2023, 9:49pm UTC](https://forums.unrealengine.com/t/float-variable-keeps-resetting-to-its-default-value/447951/5 "2023-02-07T21:49:08Z")

</div>

Hi, have you found the solution?
