After the player clicks “Play”, a tween is supposed to tween the camera’s CFrame to the player. What I did was save the camera’s CFrame into a variable before playing the initial tween, then tween it to the variable after. It doesn’t work though; the tween somewhat works, but it tweens a few studs to the left of player and it doesn’t look right. Here is the code:
local TweenService = game:GetService("TweenService")
local Lighting = game:GetService("Lighting")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local WS = game:GetService("Workspace")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local camera = WS.CurrentCamera
local camCFrame = camera.CFrame -- intitial CFrame
script.Parent.Activated:Connect(function()
TweenService:Create(script.Parent, TweenInfo.new(2), {BackgroundTransparency = 1}):Play()
TweenService:Create(script.Parent, TweenInfo.new(2), {TextTransparency = 1}):Play()
TweenService:Create(script.Parent.UIStroke, TweenInfo.new(2), {Transparency = 1}):Play()
TweenService:Create(script.Parent.Parent.TextLabel, TweenInfo.new(2), {TextTransparency = 1}):Play()
local blurTween = TweenService:Create(Lighting.Blur, TweenInfo.new(3), {Size = 0})
blurTween:Play()
blurTween.Completed:Wait()
TweenService:Create(camera, TweenInfo.new(2, Enum.EasingStyle.Sine, Enum.EasingDirection.Out), {CFrame = camCFrame}):Play() -- this is where the tween takes place
end)
Edit: I believe I read the post wrong. The script in the post is trying to go from the Player’s CFrame back to the original position. The code for the first action of Tweening to the player is not in the post. I assume that’s because it’s irrelevant to an extent.
Anyhow, I can recommend using a CFrameValue for storing the CFrame you’d like.
Old post
Based on the code in the post, it looks like the Tween for the Camera is just Tweening the Camera.CFrame to itself.
The camera variable is game.Workspace.CurrentCamera. And, the camCFrame variable is the camera variable’s .CFrame. So, I feel like the camera would not move at all here.
The way to get the Player’s CFrame, which should be the Goal of the Tween for the Camera, would be the following:
local TweenService = game:GetService("TweenService")
local playersHumanoidRootPart = game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart")
local playersCFrame = playersHumanoidRootPart.CFrame
local currentCamera = game.Workspace.CurrentCamera
-- Goal = playersCFrame
-- Start CFrame of Tween is whatever the CFrame of the Camera is when the Tween starts/is played.
-- And, you can Set the CFrame of the Camera to something by doing the following:
-- currentCamera.CFrame = CFrame.new()
local tweenCameraToThePlayer = TweenService:Create(currentCamera, TweenInfo.new(1,Enum.EasingStyle.Sine, Enum.EasingDirection.Out), { CFrame = playersCFrame } )
tweenCameraToThePlayer:Play()
I tried storing the players original CFrame in a CFrame value and parenting it to the player, then tweeting the cameras CFrame to the value, but yet again, it was offset by a few studs.