UserInputService not detecting key when other keys are pressed?

  1. What do you want to achieve?
    I want to fire a RemoteEvent when E pressed
  2. What is the issue?
    The scripts works perfectly fine, but when I walk diagonally to the right and the press E (holding W + D and pressing then E ) it doesnt detect that E is pressed. But when I walk diagonally to the left (holding W + A and pressing then E) it works tho.
  3. What solutions have you tried so far?
    I tried using different events for UserInputService
    but it still didnt work. I was searching on the dev forum, didnt work.

This is one script I was using

local inputservice = game:GetService("UserInputService")
local remoteevent = game.ReplicatedStorage.ROll
local player = game.Players.LocalPlayer

local function dashrequest()
	
	local keyspressed = inputservice:GetKeysPressed()
	
	for _, key in ipairs(keyspressed) do
		if (key.KeyCode == Enum.KeyCode.E) then
			remoteevent:FireServer(player)
		end
			
	end
end

inputservice.InputBegan:Connect(dashrequest)

And before you even begin telling me using an other even, I did.

1 Like

Put this in a LocalScript inside of StarterGui, or PlayerScripts.

It is a localscript and it is in playerscripts

Try this?

local inputservice = game:GetService("UserInputService")
local remoteevent = game.ReplicatedStorage.ROll
local player = game.Players.LocalPlayer

local function dashrequest(input)	
	if input.KeyCode == Enum.KeyCode.E then
		remoteevent:FireServer(player)
	end
end

inputservice.InputBegan:Connect(dashrequest)

I used this too but imma try it again

It sadly doesnt work too. I have to write 30 so im typing this

Can you add a print() statement whenever E is pressed so that we can find out if the error is inside the localscript or inside the remoteevent script

its inside the localscript I already did that

You don’t need to add player to the remote event, it is already being passed through. I would recommend adding prints and see what line the script stops printing. If it prints then add prints to your server script to see.

When im walking to the right diagonaly im pressing E and nothing prints but when Im doing anything else rather than walking diagonally to the right it works

Look in my other reply you can see a video there

So if it is printing then it is something wrong with the event you’re firing?

well it doesnt print when im walking diagonaly to the right

Send both client code and server code

The problem is not the server trust me. Its hard to explain, whenever I try to Roll (pressing E) it works, but when I try Rolling while im walking diagonaly to the right it doesnt work

eevent.OnServerEvent:Connect(function(plr)
	
	if otherdeb == false then
		
		eevent:FireClient(plr)
		local canslide = true
		otherdeb = true
		local hum = plr.Character:WaitForChild("Humanoid")
		local animator = hum:WaitForChild("Animator")
		local animpaly = animator:LoadAnimation(script.ROLL)
		
		if canslide == true then
			
			canslide = false
			animpaly:Play()
			local audio = script["Swoosh Pack High End Multiple Variations 20 (SFX)"]:Clone()
			wait(.2)
			audio.Parent = plr.Character.HumanoidRootPart
			audio:Play()
			wait(audio.TimeLength + .1)
			audio:Destroy()
			local slide = Instance.new("BodyVelocity")
			slide.MaxForce = Vector3.new(1,0,1) * 30000
			slide.Parent = plr.Character.HumanoidRootPart
			slide.Velocity = plr.Character.HumanoidRootPart.CFrame.lookVector * 100
		
		
			for count = 1, 4 do
				wait(0.1)
				slide.Velocity *= 0.3
			end
			
			animpaly:Stop()
			slide:Destroy()
			wait(1)
			canslide = true
		end
		wait(1)
		otherdeb = false
	end
end)




Did you try to do it faster than the cooldown in the video?

I didnt do it faster than the cooldown

Try this then I guess

local ContextActionService = game:GetService("ContextActionService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local Remote = ReplicatedStorage.ROll

function dash(actionName, inputState, inputObject)
	if inputState == Enum.UserInputState.Begin then
		Remote:FireServer()
	end
end


ContextActionService:BindAction("Dash", dash , true, Enum.KeyCode.E)

this sadly does not work either