Here is my script. It suppost to be like when you hold "Shift" you wont be able to jump.
local player = game.Players.LocalPlayer; player:GetMouse().KeyDown:connect(function (key) if key == "Shift" then humanoid.Jumping:connect(function() humanoid.Jump = false; end end) player:GetMouse().KeyUp:connect(function (key) if key == "Shift" then humanoid.Jumping:connect(function() humanoid.Jump = true; end end)
Can anyone help me with finishing this script and explain please?
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:
--This code only works on a non fe game. Local script under starterpack or startergui 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 :)