# Blueprint function returns wrong value

**URL:** <https://forums.unrealengine.com/t/blueprint-function-returns-wrong-value/430866>\
**Category:** Blueprint\
**Tags:** return, unreal-engine, UE4, question, Blueprint\
**Created:** [August 3, 2018, 9:28am UTC](https://forums.unrealengine.com/t/blueprint-function-returns-wrong-value/430866 "2018-08-03T09:28:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_9ecf23871](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_9ecf23871](https://forums.unrealengine.com/u/anonymous_user_9ecf23871)\
**Post date:** [August 3, 2018, 9:28am UTC](https://forums.unrealengine.com/t/blueprint-function-returns-wrong-value/430866/1 "2018-08-03T09:28:53Z")

</div>

![249321-klasy.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/2/1/a2124ca494bb47ff6b43d9701ae37316bf95979a.png)

This tree shows how my blueprints are made. _Class1_ has a function which returns a bool value. The problem is that when an instance of _Class3\_1_ or _Class3\_2_ (edit: actually it doesn’t work on every instance including _Class1_) uses inherited function from _Class1_ (the function call is in the _Class1_ blueprint) returned value is always true even though inside the the function everything works fine. Because of that bug loop is not stoping on the second branch node after the function is called. There is no difference if I use _Executed_ local variable or connect value directly.

 ![249322-funkcja.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/b/f/fbfcadacf30f50c6ced4c018ecf17c3f2a824d78.png)

---

<div class="post-metadata">

**Author:** ![Unfathomable](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Unfathomable](https://forums.unrealengine.com/u/Unfathomable)\
**Post date:** [August 3, 2018, 9:56am UTC](https://forums.unrealengine.com/t/blueprint-function-returns-wrong-value/430866/2 "2018-08-03T09:56:14Z")

</div>

Shot in the dark here, but is “Clip Ammo” a local variable? If so, it needs not to be.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_9ecf23871](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_9ecf23871](https://forums.unrealengine.com/u/anonymous_user_9ecf23871)\
**Post date:** [August 3, 2018, 10:09am UTC](https://forums.unrealengine.com/t/blueprint-function-returns-wrong-value/430866/3 "2018-08-03T10:09:30Z")

</div>

It’s not local, only _Executed_ is local in this blueprint

---

<div class="post-metadata">

**Author:** ![Unfathomable](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Unfathomable](https://forums.unrealengine.com/u/Unfathomable)\
**Post date:** [August 3, 2018, 12:19pm UTC](https://forums.unrealengine.com/t/blueprint-function-returns-wrong-value/430866/4 "2018-08-03T12:19:28Z")

</div>

Make your function execute the return node following “False” on your branch, otherwise it will just return a default value (it’s better to specify the value than rely on UE4 defaults).

Just tested this and if you don’t use a return node it seems to use the last return value.

I.e. call the a function that returns an int (3), and then call it again without a return node, that return will be (3). Same is happening here with your bool, it is saving “true” from the previous return.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_9ecf23871](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_9ecf23871](https://forums.unrealengine.com/u/anonymous_user_9ecf23871)\
**Post date:** [August 3, 2018, 1:09pm UTC](https://forums.unrealengine.com/t/blueprint-function-returns-wrong-value/430866/5 "2018-08-03T13:09:43Z")

</div>

Thanks, you are right, works now. 🙂
