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

How To Set Orientation Of A Part In A Tween?

Asked by 6 years ago

I made a drawer that opens and closes, but when the tween plays it changes the Orientation of the parts. I tried using Vector3 to maintain it's Orientation, but that doesn't seem to work.

local TweenService = game:GetService("TweenService")
local drawer1 = script.Parent:WaitForChild("Drawer1")
local drawer2 = script.Parent:WaitForChild("Drawer2")
local drawer3 = script.Parent:WaitForChild("Drawer3")

local tweeningInformation = TweenInfo.new(
    0.5,    
    Enum.EasingStyle.Linear,
    Enum.EasingDirection.Out,
    0,
    false,
    0

)
local drawer1Open = {CFrame = CFrame.new(31.585, 0.95, -6.635)}

local drawer2Open = {CFrame = CFrame.new(34.555, 0.924, -6.56)}

local drawer3Open = {CFrame = CFrame.new(33.15, 0.924, -8.485)}



local drawer1Close = {CFrame = CFrame.new(34.585, 0.95, -6.635)}

local drawer2Close = {CFrame = CFrame.new(37.555, 0.924, -6.56)}

local drawer3Close = {CFrame = CFrame.new(36.15, 0.924, -8.485)}



local tween1open = TweenService:Create(drawer1,tweeningInformation,drawer1Open)
local tween1close = TweenService:Create(drawer1,tweeningInformation,drawer1Close)
local tween2open = TweenService:Create(drawer2,tweeningInformation,drawer2Open)
local tween2close = TweenService:Create(drawer2,tweeningInformation,drawer2Close)
local tween3open = TweenService:Create(drawer3,tweeningInformation,drawer3Open)
local tween3close = TweenService:Create(drawer3,tweeningInformation,drawer3Close)


local clickdetector = game.Workspace.DrawerModel.Drawer1.ClickDetector
clickdetector.MouseClick:Connect(function()
    drawer1.Orientation = Vector3.new(0,0,0)
drawer2.Orientation = Vector3.new(0,0,0)
drawer3.Orientation = Vector3.new(0,90,0)

     tween1open:Play()
    tween2open:Play()
tween3open:Play()


    wait(3)
     tween1close:Play()
    tween2close:Play()
tween3close:Play()

end)
0
Simply change the position, not the CFrame. KingLoneCat 2642 — 6y

Answer this question