Camera tweening don't go back to the player normally

  1. What do you want to achieve? Hello, i have a camera tweening system to focus on a part but the leaving tween is different than the entering tween, and i want the leaving tween to be the same as the entering tween.

  2. What is the issue? The leaving tween is different than the entering tween, and there is a weird effect after the end of the tween. Here is a video to show you the issue : 2022-07-01 21-49-42

  3. What solutions have you tried so far? I tried to fix it myself and looked on forums.

We can’t help much without seeing the script, but I would suggest to save the CFrame of before the tween and use that CFrame when doing the leaving tween.

			focus = true
			local CameraCFrame = Camera.CFrame
			local CameraDistance = CameraCFrame.p - player.Character.Head.Position
			Camera.CameraType = Enum.CameraType.Scriptable
			Character.Archivable = true
			Character:WaitForChild("HumanoidRootPart").Anchored = true
			game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
			game.StarterGui:SetCore("ResetButtonCallback", false)
			ExitFocusButton.Visible = true
			tweenExitFocusButtonUp:Play()
			local tween = TweenService:Create(Camera, TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut), {CFrame = focuspart.CFrame})
			tween:Play()
			tween.Completed:Wait()

			ExitFocusButton.MouseButton1Click:Connect(function()
				local newPos = player.Character.Head.Position + CameraDistance
				local newcameraCFrame = CFrame.new(newPos, newPos + CameraCFrame.LookVector)
				tweenExitFocusButtonDown:Play()
				local tweenExit = TweenService:Create(Camera, TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut), {CFrame = CameraCFrame})
				tweenExit:Play()
				wait(1)
				Camera.CameraType = Enum.CameraType.Custom
				Camera.CameraSubject = player.Character.Humanoid
				Character:WaitForChild("HumanoidRootPart").Anchored = false
				game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, true)
				game.StarterGui:SetCore("ResetButtonCallback", true)
				wait(1)
				focus = false
				ExitFocusButton.Visible = false
			end)	

This is the script of the camera

I have a guess, which comes with a question. Does it only do this after having clicked the button once already? Sorry for the late response

Yes it does do this after having clicked the button once

Then the simple answer is because you have the Exit button’s connection inside of the Enter connection. Move the exit button’s connection outside of the Enter button’s connection.

Edit: To make this even more simple, you could just make the Exit button’s connection a variable, then disconnect it after a click.


it puts lines in error

remove the local on the CameraCFrame and the CameraDistance inside of the Enter connection, and add this at the beginning of the script.

local CameraCFrame, CameraDistance

Also, to prevent future problems, add a condition inside of the Enter connection, because I notice that it is a click detector. Add a variable called “plr” inside of the function (i mean like this function(plr)) and make sure it is equal to the local player.

do i put this at the very top of the script?

Yes, you should put it at the top of the script.

It fixed my script thank you for your help

1 Like