The watch window fails to read variables which aren’t used by the current function. Here’s a very simple example:
As you can see, the variable beta
exists and is set to true. The function doesn’t use it, and therefore the watch window fails to get the value. alpha
IS used, and the watch window is able to read it. Here’s a more detailed example:
--[[
Inside of functions, the watch window can only search for upvalues.
To my knowledge, upvalues are variables that a function needs to work as expected.
They are local values that appear up above the function, hence the name.
]]
local alpha = true
local beta = true
local function test()
print(alpha) -- If you watch for 'beta' here, it CAN NOT find the variable
--print(beta)
end
test() -- If you watch for 'beta' here, it CAN find the variable
if alpha then
print("Hello world!") -- If you watch for 'beta' here, it CAN find the variable
end
This behavior happens in all my games.
Something important to note is that this behavior is NOT occurring with native code generation. Using this feature, the bug disappears, and the watch window works as expected!
OS: Windows 11
VERSION: 0.627.0.6270453
FILE: Reproduction.rbxl (52.8 KB)
Expected behavior
I expect the watch window to be able to read every variable that has been currently assigned, in the current environment.
I also expect the variables tab to show all the declared variables. Currently, it doesn’t show ones it cannot find.