Why does Tween behave like this?

I’m very new to CFrames and i don’t understand how i can make the camera stay at the end position of the Tween.

What i’m trying to do is making the camera stay at a certain position relative to the car position and follow at the car smoothly. without any instant teleportation.

robloxapp-20210811-1315184.wmv (1.8 MB)

This is called withing a loop;

local function updateCamera()
	
    local tweenInfo = TweenInfo.new(
	    3, -- Time
	    Enum.EasingStyle.Linear, -- EasingStyle
	    Enum.EasingDirection.Out, -- EasingDirection
	    0, -- RepeatCount (when less than zero the tween will loop indefinitely)
	    false, -- Reverses (tween will reverse once reaching it's goal)
	    0 -- DelayTime
    )

    local tween = TweenService:Create(
	    workspace.Camera,
	    tweenInfo,
	    {CFrame = CFrame.new(_G.car.Visual.CameraPoints["CameraPoint" .. 
                CurrentCamera].CFrame.Position,_G.car.Chassis.BackBone.Position)}
    )

    tween:Play()

    tween.Completed:Wait()
end

This issue is most likely caused by the fact your Camera.CameraType isn’t set to CameraType.Scriptable, so after your tween finishes, it reverts back to the original camera angle since you aren’t actively updating the camera CFrame.

Sidenotes

You should use workspace.CurrentCamera instead, as that’s what the camera being used by the Players.LocalPlayer will always be. Looking for workspace.Camera may be unreliable at times.

It’s unnecessary to define every parameter in TweenInfo.new(). It would act the same if you did TweenInfo.new(3, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), and is faster to type in my opinion.

I wouldn’t suggest using _G for your script. Instead, try out a BindableEvent or look for other methods to handle the camera update.

1 Like

Thanks, is it possible to make the Tweening more “aggressive” without changing the time?

Yes; try changing the EasingStyle to something like Quint.

Thanks mate, i really appreciate the help!

1 Like