So I've been trying to make a camera that is controllable by the arrow keys (kinda like League of Legends). But in my endeavor to create this glorious camera I have ran into a problem, I don't know how to check when the key isn't being pressed anymore, so I don't know when to break. ( I also plan on copying the function "onRightKeyPress" for Left, up, & Down.)
local cameraPiece = workspace.CameraPart
local camera = workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Scriptable
camera.CameraSubject = cameraPiece
camera.CoordinateFrame = CFrame.new(cameraPiece.Position)
* CFrame.Angles(-45, 0, 0)
* CFrame.new(0, 5, 0)
function onRightKeyPress(inputObject, gameProcessedEvent)
if inputObject.KeyCode == Enum.KeyCode.Right then
while inputObject.KeyCode == Enum.KeyCode.Right do
print("Right was pressed")
workspace.CameraPart.CFrame = workspace.CameraPart.CFrame+Vector3.new(50,0,0)
camera.CoordinateFrame = CFrame.new(cameraPiece.Position)
* CFrame.Angles(-45, 0, 0)
wait(0.1)
end
end
end
game:GetService("UserInputService").InputBegan:connect(onRightKeyPress)
I have also tryed the IsKeyDown function, but it says it isn't in my library
thanks to anyone who can help

1 comment
Thanks, and I'll look into the keypress functions aswell.