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)
I don't really see anything wrong with the code, but you can try this one.
if input.KeyCode == Enum.KeyCode.W then if _G.Switch == "ON" then end end
If it doesn't work then instead of using string values "ON" or "OFF" try changing it with bool values "true" or "false", and try to stay away from global functions or try to find a way to not use it.
also can you show the whole code or particularly where it has to do something with the _G.Switch
?