Add myVar to the Watch window and it will be shown as Symbol "myVar" not in scope:
Stop
Change line 3 to print(myVar)
Run
Now myVar will be shown on My Watches:
Stop
Change line 1 to from local myVar = 123 to myVar = 123
Change back line 3 from print(myVar) to print()
Run
This way it will also be shown on My Watches:
Expected Behavior
Since myVar belongs to the function scope, it should be shown in “My Watches”
Actual Behavior myVar is only shown in “My Watches” in two cases:
If I have any reference to this variable inside the function. Ex: print(myVar).
If the variable is not declared as local. This is incongruous, as print(myVar) will print the contents of the variable, regardless of whether it is declared as local or not.
Issue Area: Studio Issue Type: Display Impact: Moderate Frequency: Constantly
After 6 months the problem continues, with the only difference that it is now showing nil (when MyVar is not mentioned inside the function (steps 1 to 4 in the op):
This is happening to me as well with the same exact reproduction steps. At first I thought it was due to watching inside of a module/on the client, but the same issue occurs regardless. Maybe I’m missing something, not entirely sure. Back to prints for now I 'spose