Why isn't this working?

Im trying to make it so that the player has to hold down Left Shift and Space to preform a long jump, but this doesn’t work, and it only functions when I hit the shift key.

UIS.InputBegan:Connect(function(Input, IsTyping)
	if state == "Running" then
		if IsTyping then return end
		if Input.KeyCode == Enum.KeyCode.LeftShift and Enum.KeyCode.Space and humanoid.Running then
			local speed = Character.Humanoid.WalkSpeed
			if IsOn then return end
			IsOn = true

			local speedBoost = speedWatch(humanoid.WalkSpeed)

			JumpAnimation:Play()

			print(speedBoost)

			humanoid.Jump = false humanoid.JumpPower = 0
			root:ApplyImpulse(root.CFrame.LookVector * (1220 * speedBoost))
			workspace.Gravity = 98.1
			root:ApplyImpulse(root.CFrame.YVector * 500)
			task.wait(0.25)
			workspace.Gravity = 196.2
			humanoid.Jump = false humanoid.JumpPower = 50


			-- Tween
			local Information = TweenInfo.new(JumpLength, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut,0,true,0)

			TweenService:Create(game.Workspace.CurrentCamera,Information, {FieldOfView = DView + 15}):Play()

			task.wait(JumpLength)
			JumpAnimation:Stop()
			task.wait(Cooldown)
			IsOn = nil
		end
	end
end)

It didn’t work.


This won’t work because Input will only be one of these at a time (plus the and statement is formatted wrong), I believe you want:
if UIS:IsKeyDown(Enum.KeyCode.LeftShift) and UIS:IsKeyDown(Enum.KeyCode.Space) and humanoid.Running then

  17:09:32.808  IsKeyPressed is not a valid member of UserInputService "Instance"  -  Client - Moveset:37
  17:09:32.810  Stack Begin  -  Studio
  17:09:32.811  Script 'Workspace.unknown.Moveset', Line 37  -  Studio - Moveset:37
  17:09:32.811  Stack End  -  Studio

Whats the point in checking if the key is pressed with a function inside of a InputBegan function?

Why not just use Enums???

its because it will detect only 1 key

Sorry, I put IsKeyPressed rather than IsKeyDown. Try what I gave now, I edited it.

Like I said, when you press LeftShift, InputBegan fires and the Input.KeyCode parameter is Enum.KeyCode.LeftShift the same thing happens when you begin pressing space, Input will not be LeftShift and Space at the same time

1 Like