# How to calculate a number between multiple of the same blueprint instances?

Blueprint amateur!
I’ve got a ForEachLoop set to either minus 1 or add 1 to an array element depending on whether a current int equals to a required int. After the loop has been completed I need the array to find the individual int values and check if they equal another number.

Basically, I want to calculate what value multiple valves blueprint instances has been put to, check if they are all the correct value after a button has been pressed. Then if they are correct, lock the valves use and open a door.
I’ve got multiple puzzles set out in the level, each an instance of this blueprint. To divide them I have each set of valves connected to a button and that button will have a “ButtonValveGroup” Integer.

I have a feeling there’s a much simpler way to do this!

So, as I understand it, you want to find out what value a variable has within another instance of a blueprint? You can link blueprints together by using blueprint casting. The “Simple Way to Reference a Target Blueprint” on this page ([Direct Actor Communication Quick Start Guide | Unreal Engine Documentation][1]) explains it really well, however if you want a shorter version then here we go:

• Create a new variable within the button blueprint and give it a name to represent the first valve. For example `Valve1`. [1]
• For `Variable Type` choose the blueprint of the valve as an object reference (NOT class) [2]. You can simply search for it by typing in the name of the valve blueprint. In my case ValveBP.
• Make sure the variable is public, by either clicking the eye symbol next to it or by checking the `Editable` box. [3]
• Compile the blueprint.
• Place the button blueprint in the level (if not done so already) and select it.
• In the details tab you can now assign a value to the newly created `Valve1` variable [4]. It will let you select between all the valve blueprint instances within your level [5]. Select the instance of the blueprint that you’d like to be the first valve.
• Back inside the button blueprint you can now simply get the `Valve1` variable and drag out from it to get certain variables within the valve blueprint [6]. (Make sure the variables you wish to get from the valve blueprint are also public ( `Editable` ) otherwise they won’t show up!) [7]

Hope this helps!

Thanks! It does help, pretty much what I’ve been doing throughout the level, just felt like I got over the top with everything being modular!