So when I’m holding down Left Shift and another key, the UIS does not recognize other keys that could be pressed down.
example:
uis.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
--// when i'm holding down this key and another key that isn't X, it won't print for when I pressed X
end
if input.KeyCode == Enum.KeyCode.X then
print("Pressed X")
if uis:IsKeyDown(Enum.KeyCode.S) then
print("Key down for S")
end
end
end)
Is there an alternative where I can account for more than two keys?
Try doing that if the key is pressed, set a value to true. Once they release it, set it to false.
Then make a while loop to detect if both values are true. Here’s what I mean. Just make sure it’s in a LocalScript.
local UIS = game:GetService("UserInputService")
local ShiftDown = false
local XDown = false
UIS.InputBegan:Connect(function(Input)
if Input.KeyCode == Enum.KeyCode.LeftShift then
ShiftDown = true
elseif Input.KeyCode == Enum.KeyCode.X then
XDown = true
end
end)
UIS.InputEnded:Connect(function(Input)
if Input.KeyCode == Enum.KeyCode.LeftShift then
ShiftDown = false
elseif Input.KeyCode == Enum.KeyCode.X then
XDown = false
end
end)
while wait() do
if ShiftDown == true and XDown == true then
print("Both keys are down!")
end
end