How to make smooth camera movement from one part to another through mouse hover?

Sorry if the explanation below is terrible, I tried to make it as simplistic to understand as possible. I’ve also shown the script in case there was anything I needed to change or add-on to it.


So I’ve made a local script where your camera snaps either left or right depending of which GUI your mouse hovers over (i.e. if your mouse hovers over a GUI on the left, your camera snaps to the left, etc) , sort of what you would see in FNAF 6’s office.

I want there to be some kind of smooth camera movement between two camera parts instead of them snapping but after hours of research, nothing worked.


If anyone could help me with this, that would be great! :smile:

Script for the the camera parts:

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
--
local Camera = workspace.CurrentCamera
--
local LeftButton = script.Parent.LeftButton
LeftButton.Active = true
local RightButton = script.Parent.RightButton
RightButton.Active = true
--
repeat wait()
Camera.CameraType = Enum.CameraType.Scriptable
until Camera.CameraType == Enum.CameraType.Scriptable
Camera.CFrame = workspace.FrontCamPart.CFrame
--
LeftButton.MouseEnter:Connect(function()
   Camera.CameraType = Enum.CameraType.Scriptable
    if Camera.CFrame == workspace.FrontCamPart.CFrame
   	Camera.CFrame = workspace.LeftCamPart.CFrame
   elseif Camera.CFrame == workspace.RightCamPart.CFrame then
   	Camera.CFrame = workspace.FrontCamPart.CFrame
   end
end)
1 Like

This is what TweenService is great for. Check out the documentation (especially the examples) on this page:

Thanks a lot for this, I finally got the camera moving between two parts as intended