Script:
game.Players.LocalPlayer:GetMouse().KeyDown:connect(function(key) if key == 47 then script.Parent:CaptureFocus() end end)
Here is the problem The capturefocus works fine, the byte is correct. In studio, I click "/" and it works fine. In online, I click "/" and it won't work (I need to press Alt, Ctrl, or Shift with it for it to work) In a local script. No error.
Use the UserInputService for whatever you're trying to do, because the "/" key and the Left-SHIFT key both have the same bytecode.
local UserInput = game:GetService("UserInputService") UserInput.InputBegan:connect(function(InputObj) if InputObj.KeyCode == Enum.KeyCode.Slash then --Do code end end)
This is the more effective way of doing it because in order for it to work, you have to press the Slash key, unlike in the keydown event where you could press the Left-SHIFT key and it would still capturefocus. Hope this helped!
Note: For more info on the UserInputService, go here: UserInputService
Use KeyUp instead of KeyDown. The wiki states some special keys like "/" can be captured by doing KeyUp instead of KeyDown.
Source: http://wiki.roblox.com/index.php?title=KeyDown_(Event)
game.Players.LocalPlayer:GetMouse().KeyUp:connect(function(key) if key == 47 then script.Parent:CaptureFocus() end end)