Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Tween not working correctly?

Asked by 4 years ago

So I want a camera to follow the player from a certain angle smoothly. Here's my code right now:

--// Client
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = workspace.CurrentCamera

--// Main
repeat wait()
    Camera.CameraType = Enum.CameraType.Scriptable
until Camera.CameraType == Enum.CameraType.Scriptable

local TweenService = game:GetService("TweenService")

local part = Camera

--// Tween
local Info = TweenInfo.new(
    3, -- Length
    Enum.EasingStyle.Sine, -- Easing Style
    Enum.EasingDirection.InOut, -- Easing Direction
    math.huge, -- Times repeated
    false, -- Reverse
    0.5 -- Delay
)

local Goals =

{
    CFrame = CFrame.new(Vector3.new(Character.HumanoidRootPart.Position.X - 15,Character.HumanoidRootPart.Position.Y + 15, Character.HumanoidRootPart.Position.Z), Vector3.new(0,0,0))
}


local tween = TweenService:Create(part,Info,Goals)
tween:Play()

Note: This is probably horribly written unintuitive code, but forgive me, I'm new to camera manipulation and tweening. If you can think of a better way to do this, please tell me.

But what's happening right now is this.

Thanks for reading, I hope you can figure out how to fix this.

Answer this question