Tween local rotation

Hello! I am using tweening for the first time and I need to make a mesh rotate in its local rotation and not the global rotation. How can I do this? I tried Orientation and CFrames and Rotations.

1 Like

You can tween by it’s rotation

game:GetService("TweenService"):Create(--[[your mesh]], tweeninfo(--[[Put your prefered tween]], {--[[Your mesh]] = CFrame.new(--[[Your mesh]].CFrame.p) * CFrame.Angles(x, y, z)} )):Play()

also you can learn more with this:

To make a mesh rotate in its local rotation rather than global rotation using tweening in Roblox, you should use a CFrame that is relative to the mesh’s current orientation. Here’s how you can achieve this:

luaCopy code

local part = game.Workspace.Part -- Replace 'Part' with the name of your mesh part
local rotationSpeed = 45 -- Adjust this value to control the rotation speed

-- Define the start and end orientations as CFrame objects
local startCFrame = part.CFrame
local endCFrame = startCFrame * CFrame.Angles(0, math.rad(90), 0) -- Rotate 90 degrees locally around the Y-axis

-- Create a TweenInfo object for your tween
local tweenInfo = TweenInfo.new(
    2, -- Duration in seconds
    Enum.EasingStyle.Linear, -- Easing style
    Enum.EasingDirection.Out, -- Easing direction
    -1, -- Number of repeats (-1 means infinite)
    true, -- Whether to reverse the tween
    0 -- Delay between repeats
)

-- Create the tween using TweenService
local tween = game:GetService("TweenService"):Create(part, tweenInfo, {
    CFrame = endCFrame -- Set the CFrame property to the end orientation
})

-- Play the tween
tween:Play()

In this example, we first define the start and end orientations as CFrame objects. The startCFrame represents the current orientation of your mesh part. To make it rotate 90 degrees locally around the Y-axis, we create the endCFrame by multiplying the startCFrame by a rotation CFrame using CFrame.Angles.

Then, we create a TweenInfo object to specify the duration, easing style, and other tweening parameters. Finally, we create a tween using TweenService and set the CFrame property to the endCFrame.

This will make the mesh rotate locally, and you can adjust the rotationSpeed and endCFrame values to control the rotation behavior as needed.

That didn’t rotate it in its local rotation.

First, create a local script and get the thing you need from the server using :WaitForChild()

local tweenService = game:GetService("TweenService")
local element = workspace:WaitForChild("Element")

local function rotate()
   tweenService:Create(element, TweenInfo.new(.7, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), {
      CFrame = element.CFrame * CFrame.Angles(0, math.rad(180), 0)
   }):Play()
end

rotate()

not rotate locally as in only for that player but the parts local rotation.

In workspace, I can change the origins orientation and that turns it in it’s local rotation. But how can use tweenservice to do that.