"scroll_vertical" value does not change for ScrollContainer in some cases

Godot Version

4.1.2

Question

Seems like inside the same function, this works in specific places, while in others it just does not


in this first image it works, the value changes with no problem, but if I put it inside the nested if (which of course I’m checking that it is accesed and printing the values) its value does not change at all. It is a very confusing behaviour, and can´t guess what the problem could be

I think that if you change the size of a ScrollContainer its scrollbars values will be invalidated until the new size gets applied in the next frame. You could try using await get_tree().process_frame before assigning the scrollbar max_value to the ScrollContainer.scroll_vertical