Tweening to player not working

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

I was able to find someone who had the solution for someone else having generally the same problem, or at least they were trying to do something similar to what you are trying to do: Link to said solution

The three arguments to TweenService:Create() should be in the order; instance to be tweened, the tween’s info & the tween’s goals.

Keep that in mind for future reference.

To set the camera’s CFrame to behind the player’s character you can do the following.

camera.CFrame = humanoidRootPart.CFrame * CFrame.new(0, 0, 4)

You may want to decrease/increase that value of 4.

I have look at that article, got nothing, Absolute nothing, I tried making it like this:

local player = game.Players.LocalPlayer
local camera = game.Workspace.CurrentCamera
local button = script.Parent.ImageButton
local looking = false
local endCFrame = game.Workspace.EventCamera.CFrame
local tweentime = 3
local debouncetime = 0.5
local active = false
local cameraCFrame
local camCFrame = camera.CFrame
local camDistance = camCFrame.p - player.Character.Head.Position -- may need to switch the order, idk
-- leaving part
local newPos = player.Character.Head.Position + camDistance
local cameraCFrame = CFrame.new(newPos, newPos + camCFrame.LookVector)
button.MouseButton1Click:Connect(function()
	if active then return end active = true
	looking = not looking
	if looking then
		cameraCFrame = camera.CFrame
		button.Image = "rbxassetid://6839989134"
		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.Image = "rbxassetid://6839981899"
		
		game.TweenService:Create(camera, TweenInfo.new(tweentime, Enum.EasingStyle.Sine, Enum.EasingDirection.Out,0,false,0), {CFrame = cameraCFrame}):Play()
		camera.CameraSubject = player.Character.Humanoid
		camera.CameraType = Enum.CameraType.Custom
		wait(debouncetime)
		player.Character.Humanoid.WalkSpeed = 16
		player.Character.Humanoid.JumpHeight = 7.2
		
	end
	active = false
end)

image
But then there is this error message

What do you mean? I dont get it

Maybe change it to FindFirstChild(“Head”), also you might need to add a wait like

Local character = player.Character or player.CharacterAdded:Wait()

So that it waits for the character to load in before doing anything that requires the character

Ah okay let me try that, thanks

If that doesn’t work or if it’s being weird, you might want to move the entering part code and leaving part code to when you click, I’m assuming entering part means in your case going from player to timer, and leaving part is from timer to player

Lemme try this, seems more convincing

How to trigger it tho? how should I call them?

Maybe you can have it like

local camCFrame
local camDistance
local newPos

Just remove the local stuff when you are changing the value of it when you click, when entering part and leaving part

I guess ill just make it like the first one, this makes a lot of error!

Alright, sorry I couldn’t be much help

Nah, u help a lot of thing, my brain just not enough to handle that lol

I tried changing your original script, I haven’t tested it so I don’t know if it works

local player = game.Players.LocalPlayer
local camera = game.Workspace.CurrentCamera
local button = script.Parent.Button
local looking = false
local camCFrame = nil
local camDistance = nil 
local newPos = nil
local cameraCFrame = nil
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
	if looking == false then
camCFrame = camera.CFrame
camDistance = camCFrame.Position - player.Character.Head.Position
		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)
                looking = true
	else
               newPos = player.Character.Head.Position + camDistance
               cameraCFrame = CFrame.new(newPos)
		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), cameraCFrame):Play() --The problem
		camera.CameraType = Enum.CameraType.Custom
		wait(debouncetime)
               looking = false
	end
	active = false
end)

Tested the script below, it works. All you need to do is save the camera’s Cframe before it’s change and then tween it back, the problem you’re having is that your setting the camera’s subject and type back to Custom and Humanoid before the tween is finished, so it makes that snap to the character, shown in one of those clips.
Here’s an example: on how it should be like: https://gyazo.com/e121a082dd5e16c68d7f17268a5af636

local Button = script.Parent
local On = false
local CamSubject = game.Workspace.Sign
local Camera = game.Workspace.CurrentCamera
local CamCFrame 
local Character = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()

Button.MouseButton1Click:Connect(function()
	if On == false then
		On = true
		CamCFrame = Camera.CFrame
		local goal = {}
		goal.CFrame = CFrame.new(CamSubject.Position + CamSubject.CFrame.LookVector * -5)
		Camera.CameraSubject = CamSubject
		Camera.CameraType = Enum.CameraType.Scriptable
		game.TweenService:Create(Camera, TweenInfo.new(0.5), goal):Play()
	elseif On == true then
		On = false
		local goal = {}
		goal.CFrame = CamCFrame
		Camera.CameraSubject = nil
		game.TweenService:Create(Camera, TweenInfo.new(0.5), goal):Play()
		wait(0.5)
		Camera.CameraType = Enum.CameraType.Custom
		Camera.CameraSubject = Character.Humanoid
	end
end)