Problems casting to another widget to get a variable.

I’m trying to cast to another widget to get a variable (a button variable). As you can see in the first picture, I want to set the visibility of the button to visible when another widget is constructed. Here are some pictures of my set up and errors.

Any ideas on what to do? Thanks!

Like the error says, you are trying to read an invalid property. Look at your code, you are setting a visibility to a widget from “S1Ref”. However, S1Ref is not defined until after you set the visibility. So S1Ref will always be null when you run Set Visibility. You need to first define what S1Ref is and then set it’s visibility.

Try switching the order between Then 0 and Then 1 output flows.

How would I go about defining it?

That didn’t do anything.

Well first switch the sequence between 0 1 like jwatte suggested. Then uncheck the “Top Level Only” from get all widgets of class. Now assuming this widget is valid, your code should work.

Do you know how to debug blueprints? Try setting a breakpoint and looking at the pin values.

The program flow in your image is wrong.

I did as you said and now I don’t get any errors, but my code still doesn’t work. The button’s visibility is not shown still. Would you like to see my design tabs of both widgets (S1Ref widget and the widget of which I’m executing the code)?

Well maybe you have more than one instance of this widget? Best thing to do is save a reference of that widget instead of using get all widgets of class. Anyway, if you want show us your code maybe we can figure out what’s wrong :slight_smile:

Ok, I will start with showing you the designer tabs.

This is the designer tab for the code we have been talking about.

This is the designer tab for the widget that adds “S1Ref” to it’s scroll box. Let me show you some of the code behind it.

This is where the code starts to execute. Ignore the other stuff and focus on the “Create Starters” function. Let me show you what’s inside of it.

Basically, I am adding widgets to the scroll box. One of these child widgets is from the “S1Ref”. The actual name of the widget is “Starter1”. That is where the button that we have been trying to make visible, is. Let me show you that widget.

As you can see, the “Here” button is what I am trying to change the visibility. By default, this button is set to Hidden. So now you know all of this, can you think of a way to solve my issue? Is there a better way of going about this?

Seems like it should work, however do you only have 1 instance of “Starter 1” ?

Yes, I only have 1 instance.

I am not sure where the problem is mate. Maybe add me on skype, I can take a look through teamviewer or something if you want.

Ok, what is your skype?

Same as here

You can search mine, extrasauce1 (it will probably come up as IcyFlames)