How to ignore other key presses?

I have a script below that checks if the player is holding the E key. Lets say if I press the R key while holding E it will stop the function because I guess the InputEnded event is firing. How do I make it so it will continue running if I am holding the E key while pressing other keys.

local UIS = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local isHolding = false
local Power = 100

	if UIS:IsKeyDown(Enum.KeyCode.E) then
		if isHolding then return end
		RunService:BindToRenderStep("Holding", Enum.RenderPriority.Input.Value, function()
			Power = Power - 1
			print("Power: "..Power)
		isHolding = true

	isHolding = false

InputEnded also has a Key argument, simply check if the Key.KeyCode == Enum.KeyCode._ to see if a certain key is being depressed

Wow that was simple thanks for solving my problem that I thought was hard lol

1 Like