How Can I Make This Camera Movement?

  1. What do you want to achieve? I want something like this:

I made this, using CameraType.Attach but it gives me another problem, the player is able to rotate the camera holding right click.

  1. What is the issue? The code I use doesnt work at all.

  2. What solutions have you tried so far? I tried diferent cameraTypes, they also gives me another problem, the player is able to rotate the camera pressing right click.
    Sorry if the code is really bad…

--This is the code that uses cameraType.Attach--
wait(1)
local UserInputService = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local rotating = false--I put rotating instead of moving for some reason xd
local camera = game.Workspace.CurrentCamera
local tween = nil
UserInputService.InputBegan:Connect(function(input,gameProccesedEvent)
	if input.KeyCode == Enum.KeyCode.A or input.KeyCode == Enum.KeyCode.Left then
		rotating = true
		while rotating == true and game.Workspace.CameraPart.Position.X <= -16 do
			local cosa = game.Workspace.CameraPart.Position
			local EndPos = Vector3.new(cosa.X + 0.3, cosa.Y, cosa.Z)
			local Tweeninfo = TweenInfo.new(0.05, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0)
			local End = {Position = EndPos}
			tween = game:GetService("TweenService"):Create(game.Workspace.CameraPart, Tweeninfo, End)
			tween:Play()
			camera.CameraType = Enum.CameraType.Attach
			camera.CameraSubject= game.Workspace.CameraPart 
			wait(0.01)
		end
	   
	end

         
end)
UserInputService.InputEnded:Connect(function(input,gameProccesedEvent)
	if input.KeyCode == Enum.KeyCode.A or input.KeyCode == Enum.KeyCode.Left then
		rotating = false
	end
end)

1 Like

I had a similar problem to this when I made a camera lock on system. I belive I solved it by binding an empty action to right click with Context Action Service.

2 Likes

Thanks!, that works great on computers, is there anyway to do it on phone/tablets?

1 Like

my options:
best cameratype for custom movement: Scriptable
best for player camera movement: Custom
sorry if this doesn’t help

1 Like

Even when the camera is on scriptable you can still rotate it holding the right mouse button

1 Like

That should not happen at all.

Do you have any camera movement code? Also, have you made 100% sure that the camera is scriptable .

2 Likes