That is pretty odd. What if you swap A and D? Does D still work? I’m not sure why it would change, but it’s worth a try just to rule out some issue with the control flow that we’re not seeing.
If all else fails, you should be able to track the states of the WASD keys yourself by using InputBegan and InputEnded. If that still doesn’t work, you can add some prints to see if the A key is getting an unexpected InputEnded when you press Q - if so, it’s the keyboard issue I mentioned.
That isn’t the problem here. IsKeyDown(A) should return true if the A key is down regardless. OP here is trying to check the state of the A key when the Q key is pressed, not the other way around.
Are you totally sure the “Left” event works, then? I guess it would’ve printed “A” before though.
I guess you could try tracking the key states yourself then.
local keyStates = {}
local keysToTrack = { [Enum.KeyCode.A]=true, [Enum.KeyCode.D]=true, [Enum.KeyCode.W]=true, [Enum.KeyCode.S]=true }
UIS.InputBegan:Connect(function(inputObj, processed)
if processed then return end
if keysToTrack[inputObj.KeyCode] then
keyStates[inputObj.KeyCode] = true
end
if inputObj.KeyCode == Enum.KeyCode.Q then
if keyStates[Enum.KeyCode.A] then
game.ReplicatedStorage.RemoteEvents.RollEvent:FireServer("Left")
elseif keyStates[Enum.KeyCode.D] then
--so on
end
end)
UIS.InputEnded:Connect(function(inputObj, processed)
if keysToTrack[inputObj.KeyCode] then
keyStates[inputObj.KeyCode] = false
end
end)
It’s not working because for each key press the function runs seperately so Input.KeyCode cannot be Q and A simultaneously, instead you can check if you are holding Q and then check if you pressed A while you are holding Q. Here is some code:
local UserInputService = game:GetService("UserInputService")
local HoldingQ = false
UserInputService.InputBegan:Connect(function(Input,GPE)
if GPE then return end
if Input.KeyCode == Enum.KeyCode.Q then
HoldingQ = true
elseif Input.KeyCode == Enum.KeyCode.A and HoldingQ then
print("Holding Q and pressed A")
end
end)
UserInputService.InputEnded:Connect(function(Input)
if Input.KeyCode == Enum.KeyCode.Q then
HoldingQ = false
end
end)
You can also shorten this code by including UserInputSerivce:IsKeyDown(keyCode) like this:
local UserInputService = game:GetService("UserInputService")
UserInputService.InputBegan:Connect(function(Input,GPE)
if GPE then return end
if Input.KeyCode == Enum.KeyCode.A and UserInputService:IsKeyDown(Enum.KeyCode.Q) then
print("Holding Q and pressed A")
end
end)
that wont work, the roll script works by sombody pressing Q while hold one of the four WASD, WASD is for the direction and pressing Q just activates the roll
dosent work, im gonna still keep the code though because it looks nice. I was testing with the search bar in google. It might be a keyboard issue, not entirely sure though, have to wait for my friend to get on to test with his keyboard