I have a configuration editor in one of my projects, so players can adjust certain game variables to change the game to suit their skill level and tastes. I made a GUI for it, with an object that you can click on to increment a variable up or down. One of the game variables is constrained to a range of values between 1 and 9. The game configuration can be edited to change the min/max values of this random range, within the 1-9 range. That is to say, you can make min be any number between 1-9, and max can be any number between 1-9, and min must be <= max. So, the default range is 1-9, but by editing the config, the player may select a different range within those constraints, say 3-7, or 5-5. But never can the range be inverted, for example a range of 7-4 would not be allowed. The game variables are stored in a ds_map, and when I finalize the config changes, the ds_map gets converted to json and written to an external file. When the game launches, it checks for this file, and if it finds the file, the json is read out of it, converted back into a ds_map, and the variables are used in the game. This all works, with one weird glitch that I don't understand: With the range variable I mentioned above, if I increase the minimum bound of the range above the current maximum bound of the range, the way my code works, it automatically increases the maximum range value so that the range is never upside down. The weird part about this is, say min_range and max_range are both currently equal to 6. I click the up button on the min_range value. The expected result of this should be that min_range gets increased by 1, so should now be 7. And since min_range is now higher than max_range, this should therefore bump the max_range variable to be 7 as well. And this does happen, but it takes two clicks. The first click, max_range increases -- even though I'm clicking on the min_range++ button. The second click, min_range now increases. I can't understand why my code does this. The relevant snippet of code is as follows: Code: ///Step Event var temp_min = clamp(switches[? "min"].value, 1, switches[? "max"].value); var temp_max = clamp(switches[? "max"].value, switches[? "min"].value, 9); switches[? "min"].value = temp_min; switches[? "max"].value = temp_max; Prior to this version of my code, I was just updating the variables directly, without the temp variables, like this: Code: ///Step Event switches[? "min"].value = clamp(switches[? "min"].value, 1, switches[? "max"].value); switches[? "max"].value = clamp(switches[? "max"].value, switches[? "min"].value, 9); When this ran, it would update the max variable in the same step as the min variable if I incremented min to be higher than max. But if I tried to decrement max, it would halt when its value was equal to min, unable to decrement below min. If I reversed the order of execution of the two lines of code, then it would work in reverse -- I could decrement max below min, and min would update to be equal to the new value of max in the same step, but then I couldn't increase min above max and have max increase. What I want is that when I increase min_range, min_range would increase, and max_range should be pushed upwards if need be, both incrementations in the same step, and when I decrease max_range, max_range would decrease, and min_range would get pushed downward if need be. The temp variable approach kindof-almost works, I just can't figure out why I have to click the control twice, and why when I click it the first time, the variable controlled by the other button increases first while the variable I'm clicking to change remains where it is. I've been thinking about it for two days, and I just can't seem to understand my own code. So I'm asking the community: 1) Why is my code behaving this way? 2) How can I write the code to behave in the way I want it to?