How would I be able to detect 2 keys being held down to print something out?
I’m trying to get A and D held down to print out “Hold”
UserInputService = game:GetService("UserInputService")
local aKeyPressed = false
local dKeyPressed = false
-----------------------------------------------------------------------------------
UserInputService.InputBegan:Connect(function(input,gameProcessedEvent)
if input.KeyCode == Enum.KeyCode.A then
aKeyPressed = true
while aKeyPressed == true do
wait()
print("Left")
end
end
end)
UserInputService.InputEnded:Connect(function(input,gameProcessedEvent)
if input.KeyCode == Enum.KeyCode.A then
aKeyPressed = false
end
end)
-----------------------------------------------------------------------------------
UserInputService.InputBegan:Connect(function(input,gameProcessedEvent)
if input.KeyCode == Enum.KeyCode.D then
dKeyPressed = true
while dKeyPressed == true do
wait()
print("Right")
end
end
end)
UserInputService.InputEnded:Connect(function(input,gameProcessedEvent)
if input.KeyCode == Enum.KeyCode.D then
dKeyPressed = false
end
end)