A way to have something happen when the left/right arrow key is pressed
The camera moves and not anything with input happens
I have not found any solutions.
Here is my current Code:
local USI = game:GetService("UserInputService")
local UpPressed = false
local DownPressed = false
local LeftPressed = false
local function GetCool(Input)
if Input.KeyCode == Enum.KeyCode.Up then
UpPressed = true
print("Up Pressed!")
elseif Input.KeyCode ~= Enum.KeyCode.Down then
UpPressed = false
print("Up Not Pressed!")
end
if Input.KeyCode == Enum.KeyCode.Down and UpPressed == true then
DownPressed = true
print("Down Pressed!")
elseif Input.KeyCode ~= Enum.KeyCode.Left then
DownPressed = false
print("Down Not Pressed!")
end
if Input.KeyCode == Enum.KeyCode.Left and DownPressed == true then
LeftPressed = true
print("Left Pressed!")
elseif Input.KeyCode ~= Enum.KeyCode.Right then
LeftPressed = false
print("Right Not Pressed!")
end
if Input.KeyCode == Enum.KeyCode.Right and LeftPressed == true then
UpPressed = false
DownPressed = false
LeftPressed = false
print("Right Pressed!")
end
end
USI.InputEnded:connect(function(Input)
GetCool(Input)
end)
Any help will be appreciated!
This is for a secret for my upcoming game not yet released!
I think you’ll also need to add an InputBegan connection like you did with InputEnded to make it run when the user presses the key down, not just when they let go of it.
local UIS = game:GetService("UserInputService")
UIS.InputBegan:Connect(function(input, gameProccessedEvent)
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.Up then
--function
end
end
end)
I have provided the script and I am intending for it to happen when the key is lifted and the Up/Down arrows work but I am only having issues with Left/Right keys
local USI = game:GetService("UserInputService")
local UpPressed = false
local DownPressed = false
local LeftPressed = false
local RightPressed = false
local function GetCool(Input)
if Input.UserInputType == Enum.UserInputType.Keyboard then
if Input.KeyCode == Enum.KeyCode.Up then
UpPressed = true
print("Up Pressed!")
elseif Input.KeyCode ~= Enum.KeyCode.Down then
UpPressed = false
print("Up Not Pressed!")
end
if Input.KeyCode == Enum.KeyCode.Down then
DownPressed = true
print("Down Pressed!")
elseif Input.KeyCode ~= Enum.KeyCode.Up then
DownPressed = false
print("Down Not Pressed!")
end
if Input.KeyCode == Enum.KeyCode.Left then
LeftPressed = true
print("Left Pressed!")
elseif Input.KeyCode ~= Enum.KeyCode.Right then
LeftPressed = false
print("Left Not Pressed!")
end
if Input.KeyCode == Enum.KeyCode.Right then
RightPressed = true
print("Right Pressed!")
elseif Input.KeyCode ~= Enum.KeyCode.Left then
RightPressed = false
print("Right Not Pressed!")
end
end
end
USI.InputEnded:connect(function(Input)
GetCool(Input)
end)
local USI = game:GetService("UserInputService")
local UpPressed = true
local DownPressed = true
local LeftPressed = true
local RightPressed = true
local function GetCool(Input)
if Input.UserInputType == Enum.UserInputType.Keyboard then--and Input.KeyCode == Enum.KeyCode.Up or Input.KeyCode == Enum.KeyCode.Down or Input.KeyCode == Enum.KeyCode.Right or Input.KeyCode == Enum.KeyCode.Left then
if Input.KeyCode == Enum.KeyCode.Up then
UpPressed = true
print("Up Pressed!")
elseif Input.KeyCode == Enum.KeyCode.Down then
UpPressed = false
print("Up Not Pressed!")
end
if Input.KeyCode == Enum.KeyCode.Down then
DownPressed = true
print("Down Pressed!")
elseif Input.KeyCode == Enum.KeyCode.Up then
DownPressed = false
print("Down Not Pressed!")
end
if Input.KeyCode == Enum.KeyCode.Left then
LeftPressed = true
print("Left Pressed!")
elseif Input.KeyCode == Enum.KeyCode.Right then
LeftPressed = false
print("Left Not Pressed!")
end
if Input.KeyCode == Enum.KeyCode.Right then
RightPressed = true
print("Right Pressed!")
elseif Input.KeyCode == Enum.KeyCode.Left then
RightPressed = false
print("Right Not Pressed!")
end
end
end
USI.InputEnded:connect(function(Input)
GetCool(Input)
end)
This would not work since I am forcing the player to press “Up > Down > Left > Right” since these have no checks for if the keys are pressed in the correct order.
The Left and Right Arrow Keys are grabbed by the camera and uses UserInputService as well,
ie. They aren’t bound with ContextActionService.
But there is a flag that can prevent the camera from grabbing the left and right arrows for panning.
You’ll have to grab the activeCameraController and then set its .keyPanEnabled to false.
(Something to research, or maybe someone else will take the time to explain it more.)
Hey i know this topic conversation was inactive for a while but, i have the same problem and i can’t find any other topics about how to get activeCameraController, can you tell the way you made your code run successfully or link the topic you have viewed ?
There seems to be no documentation at all about activeCameraController and .keyPanEnabled … could you explain how you fixed this issue?? This is extremely frustrating as I can’t find any help online