Tweening to player not working

So I want to make if you click a button, your camera moved to a part, then if you press again, your camera get back to the player
But I find this problem:

local player = game.Players.LocalPlayer
local camera = game.Workspace.CurrentCamera
local button = script.Parent.Button
local looking = false
local endCFrame = game.Workspace.EventCamera.CFrame
local tweentime = 3
local debouncetime = 0.5
local active = false
button.MouseButton1Click:Connect(function()
	if active then return end active = true
	looking = not looking
	if looking then
		button.Text = "Go Back!"
		player.Character.Humanoid.WalkSpeed = 0
		player.Character.Humanoid.JumpHeight = 0
		camera.CameraType = Enum.CameraType.Scriptable
		game.TweenService:Create(camera, TweenInfo.new(tweentime, Enum.EasingStyle.Sine, Enum.EasingDirection.Out,0,false,0), {CFrame = endCFrame}):Play()
		wait(tweentime+debouncetime)
	else
		button.Text = "See Timer!"
		player.Character.Humanoid.WalkSpeed = 16
		player.Character.Humanoid.JumpHeight = 7.2
		game.TweenService:Create(endCFrame, TweenInfo.new(tweentime, Enum.EasingStyle.Sine, Enum.EasingDirection.Out,0,false,0), camera):Play() --The problem
		camera.CameraType = Enum.CameraType.Custom
		wait(debouncetime)
	end
	active = false
end)
game.TweenService:Create(endCFrame, TweenInfo.new(tweentime, Enum.EasingStyle.Sine, Enum.EasingDirection.Out,0,false,0), camera):Play()

This is where the problem happened
Thanks, hopefully someone can fix this!

1 Like

You are trying to tween the CFrame (endCFrame) you need to change it to camera

Ah, got it so it should be like this right?

game.TweenService:Create(camera, TweenInfo.new(tweentime, Enum.EasingStyle.Sine, Enum.EasingDirection.Out,0,false,0), camera):Play()`

Do you want it to tween back to the character?

Yes, exactly, to player’s first camera position

you would tween it to the characters primary part cframe

game.TweenService:Create(camera, TweenInfo.new(tweentime, Enum.EasingStyle.Sine, Enum.EasingDirection.Out,0,false,0), {CFrame = player.Character.PrimaryPart.CFrame}):Play()

Ah okay, let me try this! thanks

Nope, its making me to look at character’s torso

because then you need to change the camera subject to the humanoid

game.TweenService:Create(camera, TweenInfo.new(tweentime, Enum.EasingStyle.Sine, Enum.EasingDirection.Out,0,false,0), {CFrame = player.Character.PrimaryPart.CFrame}):Play()
camera.CameraSubject = player.Character.Humanoid

Oh ok let me try that, thank you

Still the same, its doing like this:
(https://gyazo.com/31cd86189a91fb8d7b0fe92a8afd7e76)

Does this work?

local player = game.Players.LocalPlayer
local camera = game.Workspace.CurrentCamera
local button = script.Parent.Button
local looking = false
local endCFrame = game.Workspace.EventCamera.CFrame
local tweentime = 3
local debouncetime = 0.5
local active = false
local cameraCFrame
button.MouseButton1Click:Connect(function()
	if active then return end active = true
	looking = not looking
	if looking then
        cameraCFrame = camera.CFrame
		button.Text = "Go Back!"
		player.Character.Humanoid.WalkSpeed = 0
		player.Character.Humanoid.JumpHeight = 0
		camera.CameraType = Enum.CameraType.Scriptable
		game.TweenService:Create(camera, TweenInfo.new(tweentime, Enum.EasingStyle.Sine, Enum.EasingDirection.Out,0,false,0), {CFrame = endCFrame}):Play()
		wait(tweentime+debouncetime)
	else
		button.Text = "See Timer!"
		player.Character.Humanoid.WalkSpeed = 16
		player.Character.Humanoid.JumpHeight = 7.2
		game.TweenService:Create(camera, TweenInfo.new(tweentime, Enum.EasingStyle.Sine, Enum.EasingDirection.Out,0,false,0), {CFrame = cameraCFrame}):Play() --The problem
		camera.CameraType = Enum.CameraType.Custom
		wait(debouncetime)
	end
	active = false
end)

What is cameraCFrame? cuz its not defined in the script

In the script I just posted it is
Its the position of the camera before it was tweened to the board

Lemme try that first, wait a minute

The result:
(https://gyazo.com/813ffc60feb7b4039feef5a349d0ce7c)
still not like what i wanted it to be

I still dont get this! I dont know whats wrong

Just for example, this is what I want to do when player press the button:
(https://gyazo.com/f559126aa8461ba9707a610a09108650)

Still, I cant find any solutions that help. Prob no one know how to do this