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

How do I stop a tween from automatically changing orientation?

Asked by
CodyDev 70
6 years ago

I'm making doors for somebody, and I'm using TweenService for it. It's not moving my doors properly sometimes. I feel like this is a silly mistake.

Code: (only variables)

local tweens = game:GetService("TweenService")
local tweeninfo = TweenInfo.new(
    1.3,
    Enum.EasingStyle.Sine,
    Enum.EasingDirection.In,
    0,
    false,
    0
)

local doorAopened = {CFrame = CFrame.new(s.DoorAOpen.Position)}
local doorBopened = {CFrame = CFrame.new(s.DoorBOpen.Position)}
local doorAclosed = {CFrame = CFrame.new(s.DoorAClosed.Position)}
local doorBclosed = {CFrame = CFrame.new(s.DoorBClosed.Position)}

local doorAopen = tweens:Create(doorA,tweeninfo,doorAopened)
local doorBopen = tweens:Create(doorB,tweeninfo,doorBopened)
local doorAclose = tweens:Create(doorA,tweeninfo,doorAclosed)
local doorBclose = tweens:Create(doorB,tweeninfo,doorBclosed)

Gif of what happens: https://i.imgur.com/Gob8XGI.gifv

The broken door is rotated, so the doors have an orientation property of 0,-90,0. The normal door has an orientation of 0,0,0. I believe what is happening is that the tweens are automatically tweening the orientation property of the doors to 0,0,0 even though I did not specify it.

I tried this and copied it for each one, but it didn't work.

local doorAopened = {}
doorAopened.CFrame = CFrame.new(s.DoorAOpen.Position)
doorAopened.Orientation = Vector3.new(0,0,0)

Anyone know how to fix this?

1 answer

Log in to vote
1
Answered by
lukeb50 631 Moderation Voter
6 years ago

CFrame contains information related to rotation. If you try to create a CFrame from a Vector3(Position) it will set all rotation values of the CFrame to 0. The simplest fix would be to edit your position defining lines like this:

local doorAopened = {CFrame = s.DoorAOpen.CFrame}

That way you preserve rotation information.

Hope this helped!

0
Ha, I knew it was a silly mistake. Thanks. CodyDev 70 — 6y
Ad

Answer this question