Camera snapping

hello, im making a camera transition from the part to the players head/camera, but it keeps snapping to x-15 for some reason. video below

repeat wait() until game:IsLoaded()
local Players = game:GetService("Players")
local TweenService = game:GetService("TweenService")
local UIS = game:GetService("UserInputService")

local Player = Players.LocalPlayer
local Board = workspace.Board
local CameraPart = workspace.CameraLock

local Menu = Board.SurfaceGui.Menu

local Camera = workspace.CurrentCamera

local Focused = false
local FocusID = 0

local CFrameBeforeFocus = CFrame.new(0,0,0)

local function FocusBoard()
	FocusID = math.random(1,999999) * math.random(2,9999999)
	Focused = true
	
	Board.ClickDetector.MaxActivationDistance = 0
	Player.Character.Humanoid.WalkSpeed = 0
	Camera.CameraType = Enum.CameraType.Scriptable
	CFrameBeforeFocus = Camera.CFrame
	TweenService:Create(Camera, TweenInfo.new(1, Enum.EasingStyle.Quint, Enum.EasingDirection.Out), {CFrame = CameraPart.CFrame}):Play()
end

local function Return()
	local SavedFocusID = FocusID
	Focused = false
	
	TweenService:Create(Camera, TweenInfo.new(1, Enum.EasingStyle.Quad), {CFrame = CFrameBeforeFocus}):Play()
	task.spawn(function()
		task.wait(1)
		if not Focused and SavedFocusID == FocusID then
			Camera.CameraType = Enum.CameraType.Follow
			Board.ClickDetector.MaxActivationDistance = 32
			Player.Character.Humanoid.WalkSpeed = 16
		end
	end)
end

Board.ClickDetector.MouseClick:Connect(function()
	FocusBoard()
end)

Menu.Return.Activated:Connect(function()
	Return()
end)

UIS.InputBegan:Connect(function(i, p)
	if p then return end
	
	if i.KeyCode == Enum.KeyCode.Space then
		if Focused then
			Return()
		else
			FocusBoard()
		end
	end
end)
1 Like

I’m not too sure. Only thing I would try is setting the cameratype before tweening back.

that kinda worked, the only issue is the position isnt getting tweened

I thought it is?

yeah but when i put the cameratype to follow before tweening, it gets overwritten, so it only tweens the orientation

1 Like

Oh, I see. So probably is better to do it after the tween, after all, huh :thinking:

I remember dealing with this sort of thing before. It was an odd behavior. Difficult. I’ll try finding old scripts

1 Like

okay, thanks! thirtychrrr

Hey again. I’m sorry, but I checked and the game I was thinking of I hadn’t actually solved that issue. Seems it was a mystery for me.

1 Like

hmmm, alright. i’ll try to find a solution. thanks!

1 Like