I know that the tittle may be a bit confusing but i'll explain. I'm trying to make a script that only fires when the player is pressing W and _G name is set to "ON". That's the script:
game:GetService("UserInputService").InputBegan:connect(function(input)
if input.KeyCode == Enum.KeyCode.W and _G.Switch == "ON" then
I don't know why it's not executing, and when i remove _G part it works well. I think that the error is in the second line, can someone help please?
(sorry for the bad english, it's not my primary language)

2 comments
Instead of using a global variable I suggest using bool values and then try and see if it's still a problem.
I try to stay away from global variables to be honest