There's a few issues here. Firstly, GetMouse is deprecated if I'm correct. Secondly, the 'connect' is put after the if. In short, after they click shift once, then when they jump they will be forced to keep jumping, because BOTH pieces have been connected. A better way to go about this is:
local player = game.Players.LocalPlayer
local allowed = true
local function onKeyPress(inputObject, gameProcessed)
if inputObject.KeyCode == Enum.KeyCode.LeftShift or inputObject.KeyCode == Enum.KeyCode.RightShift then
allowed = false
end
end
local function onKeyLeft(inputObject, gameProcessed)
if inputObject.KeyCode == Enum.KeyCode.LeftShift or inputObject.KeyCode == Enum.KeyCode.RightShift then
allowed = true
end
end
repeat wait() until player.Character ~= nil
player.Character.Humanoid.Jumping:Connect(function()
if not allowed then
player.Character.Humanoid.Jump = false
end
end
game:GetService("UserInputService").InputBegan:Connect(onKeyPress)
game:GetService("UserInputService").InputEnded:Connect(onKeyLeft)
Please accept the answer if it was useful :)
2 comments
This method of keyboard input is deprecated
Deprecated.