# Function inside function doesn't return value

**URL:** <https://forums.unrealengine.com/t/function-inside-function-doesnt-return-value/2104599>\
**Category:** Blueprint\
**Tags:** unreal-engine, Blueprint, question\
**Created:** [November 4, 2024, 4:20pm UTC](https://forums.unrealengine.com/t/function-inside-function-doesnt-return-value/2104599 "2024-11-04T16:20:21Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![AllGamesSuck](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AllGamesSuck](https://forums.unrealengine.com/u/AllGamesSuck)\
**Post date:** [November 4, 2024, 4:20pm UTC](https://forums.unrealengine.com/t/function-inside-function-doesnt-return-value/2104599/1 "2024-11-04T16:20:21Z")

</div>

Hi, in my blueprint function library, I have a recursive function that adds values to a local map variable and then returns this map variable. All good inside the function, I can see the values on the return node.  
But when I call this function inside another function, it doesn’t return anything, the map variable is empty.  
I even added a text variable on the return node to see if that gets passed, and nothing. It sometimes even crashes the engine.  
What gives?

 ![first](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/f/c/3fcc2fef49353ef58ae2a7e4a28bb2a9b30cffc3.jpeg)

---

<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:** [November 4, 2024, 4:49pm UTC](https://forums.unrealengine.com/t/function-inside-function-doesnt-return-value/2104599/2 "2024-11-04T16:49:16Z")

</div>

> [@AllGamesSuck](#):
>
> What gives?

What is shown is poorly scripted and seems unsafe 🤷

* * *

- cache the data, avoid accessing data pins from other exec branches. While it _should_ technically work here since it’s a Break loop, I would not rely on this - it is asking for trouble and I’d expect it to eventually crash:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/1/9/a19afc84251db29c96663d7d3e18b831c4267ecb.jpeg)

Found what you needed? cache it, break, complete, use cache. Done with the cache? Push it back into the container.

- no return will return defaults. Intended? That’s the recursion, right? Also, why not take a screenshot that has more than just a handful of pixels…

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/5/9/c591e1edee5e9fa530192dd2ec2d97f528ec2b12.png)

- the loop at the bottom doesn’t do anything

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/6/6/466c0b01731ff357d0b64e22c4e764ee789b0d5b.png)

- tMaps can be passed by ref; here, you’re passing a copy. This may be irrelevant for the very described issue, but may as well be a neat solution. Not enough info to tell more, though.

---

<div class="post-metadata">

**Author:** ![Dejan33](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/dejan33/32/1194514_2.png) [@Dejan33](https://forums.unrealengine.com/u/Dejan33)\
**Post date:** [November 4, 2024, 4:54pm UTC](https://forums.unrealengine.com/t/function-inside-function-doesnt-return-value/2104599/3 "2024-11-04T16:54:05Z")

</div>

Because of low quality picture , what are you removing?

---

<div class="post-metadata">

**Author:** ![AllGamesSuck](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AllGamesSuck](https://forums.unrealengine.com/u/AllGamesSuck)\
**Post date:** [November 4, 2024, 6:02pm UTC](https://forums.unrealengine.com/t/function-inside-function-doesnt-return-value/2104599/4 "2024-11-04T18:02:07Z")

</div>

I took it node by node. Apprently, calling the function within itself, the way I did it, breaks it. So I made a new simple function:

 ![Capture](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/d/e/1deae77f61f995f37b3913858d52ec2e525e690a.jpeg)  
And the result is also 0. So what am I doing wrong here?

Also, I don’t know what you mean by “cache it”. How do I do that? And why is it “unsafe scripting”? What can I do better?

---

<div class="post-metadata">

**Author:** ![Dejan33](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/dejan33/32/1194514_2.png) [@Dejan33](https://forums.unrealengine.com/u/Dejan33)\
**Post date:** [November 4, 2024, 6:11pm UTC](https://forums.unrealengine.com/t/function-inside-function-doesnt-return-value/2104599/5 "2024-11-04T18:11:16Z")

</div>

what is the initial value of new param?

---

<div class="post-metadata">

**Author:** ![Dejan33](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/dejan33/32/1194514_2.png) [@Dejan33](https://forums.unrealengine.com/u/Dejan33)\
**Post date:** [November 4, 2024, 6:20pm UTC](https://forums.unrealengine.com/t/function-inside-function-doesnt-return-value/2104599/6 "2024-11-04T18:20:04Z")

</div>

If it is 0 then the last one should return 4, but this will not return because you are not returning it (from the true branch).

---

<div class="post-metadata">

**Author:** ![AllGamesSuck](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AllGamesSuck](https://forums.unrealengine.com/u/AllGamesSuck)\
**Post date:** [November 4, 2024, 7:10pm UTC](https://forums.unrealengine.com/t/function-inside-function-doesnt-return-value/2104599/7 "2024-11-04T19:10:03Z")

</div>

Yep, that was it. I didn’t think I’d need a return node there as well, since I have one when the function ends. Which leaves me a bit confused, but it works.  
Thanks a lot.

---

<div class="post-metadata">

**Author:** ![AllGamesSuck](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AllGamesSuck](https://forums.unrealengine.com/u/AllGamesSuck)\
**Post date:** [November 4, 2024, 7:11pm UTC](https://forums.unrealengine.com/t/function-inside-function-doesnt-return-value/2104599/8 "2024-11-04T19:11:03Z")

</div>

> [@Everynone](#):
>
> What is shown is poorly scripted and seems unsafe 🤷

Thanks. What do you mean by that?

---

<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:** [November 4, 2024, 7:29pm UTC](https://forums.unrealengine.com/t/function-inside-function-doesnt-return-value/2104599/9 "2024-11-04T19:29:58Z")

</div>

Have a look at the 4 bullet points.

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [December 4, 2024, 7:30pm UTC](https://forums.unrealengine.com/t/function-inside-function-doesnt-return-value/2104599/10 "2024-12-04T19:30:12Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
