CFrame Tween not animating

Hello :wave:,
I’m trying to make a tween work with a look vector, however, instead of tweening to the desired position, it just teleport. Any help is appreciated.

My code:

-- Doors

local left = script.Parent.Parent.Left

local right = script.Parent.Parent.Right

-- Services

local TweenService = game:GetService("TweenService")

-- Config

local Config = require(script.Parent.Parent.Configuration)

-- Tablet position.

local Tablets = script.Parent.Parent.Tablets

-- UI Buttons

local Lock = Tablets:GetDescendants("Locked")

local ForceOpen = Tablets:GetDescendants("Force Open")

local ForceClose = Tablets:GetDescendants("Force Close")

local FireMode = Tablets:GetDescendants("Fire Mode")

local Hold = Tablets:GetDescendants("Hold")

-- Player Detection

local PlayerDetection = script.Parent.Parent.PlayerDetection

local DetectPart = PlayerDetection:GetDescendants()

-- Tweens

local TweenLInfo = TweenInfo.new(

10, --Time

Enum.EasingStyle.Linear, -- Style of door open animation

Enum.EasingDirection.In, -- Direction of easing.

-1, -- Repeat count.

false, -- Will it reverse?

0 -- The delay time.

)

-- open look vectors

wait (10)

local LTween = TweenService:Create(left, TweenLInfo, {Value = left:SetPrimaryPartCFrame(CFrame.new(left.PrimaryPart.CFrame.lookVector * 14))})

LTween:Play()

Do this instead :

local LTween = TweenService:Create(left, TweenLInfo, {Position = left:SetPrimaryPartCFrame(CFrame.new(left.PrimaryPart.CFrame.lookVector * 14))})

1 Like

Hmmmm, it still just teleports! I think it’s playing the CFrame before the tween.

what about using CFrame instead of Position?

Nope, still teleports. I tested if it was happening before or after :play() and it’s teleporting to the desired position before the tween plays.

Found the problem
You are using a function inside of the tween
Try this instead

local LTween = TweenService:Create(left, TweenLInfo, {CFrame = CFrame.new(left.PrimaryPart.CFrame.lookVector * 14))})
1 Like

I got back the error
Workspace.AutomaticDoor.Configuration.Controller:43: Expected ‘}’ (to close ‘{’ at column 54), got ‘)’

Very strange :thinking:

Oh sorry. I forgot to remove one of the parentheses

local LTween = TweenService:Create(left, TweenLInfo, {CFrame = CFrame.new(left.PrimaryPart.CFrame.lookVector * 14)})

Try now.
Edit: Sorry didn’t copy all of the define.

Hmmm,
It now gives me this error:
TweenService:Create no property named ‘CFrame’ for object ‘Left’

I’m still learning CFrame so combining with a tween has been a challenge so far.

try this

local LTween = TweenService:Create(left.PrimaryPart, TweenLInfo, {CFrame = CFrame.new(left.PrimaryPart.CFrame.lookVector * 14)})
1 Like

Here are two other ones that might work

local LTween = TweenService:Create(left, TweenLInfo, {Position = CFrame.new(left.PrimaryPart.CFrame.lookVector * 14)})
local LTween = TweenService:Create(left, TweenLInfo, {Value = CFrame.new(left.PrimaryPart.CFrame.lookVector * 14)})
1 Like

It now animates, however, it’s going in the wrong direction and it doesn’t drag the whole model just the part.

are the parts welded to the primarypart? if not that may be the reason

I tried welding them, however, it still just dragged the one part. Are there any good plugins for a weld? The plugin I used seems to break it but im not sure.

Ok for the direction do

local LTween = TweenService:Create(left, TweenLInfo, {Position = CFrame.new(-left.PrimaryPart.CFrame.lookVector * 14)})

Now for dragging the whole model you can:
Make a union
Do the tween for each and every part
Use attachments

I use one called rigEdit Lite which works pretty well
Also useful for rigging other than just welding

Well it’s moving diagonally no matter what i change the position to, even if i use rightvector etc so - would only make it move the opposite way diagonally. I need it to move left (in terms of the buildings angle) in which i’d reverse the lookvector however for some reason the lookvector is going diagonal.

Okay, thank you i’ll try use that one!

Ok. I believe look vectors are random. Is there n exact position you want it to go to?

1 Like

Yes, however, I want to make it so if i rotate/move the model I won’t have to change the position.