Way to Tween Orientation?

I am making a gun, and when it shoots I want its orientation to change from 0,0,-90 to 0,0,-110.

I know how to change it, but is there a way to tween it so the recoil of my gun is smooth?

Basically, I want to make it so I can change orientation smoothly.

You could probably tween the ‘GripUp’ property of the tool, this is essentially the CFrame.UpVector of the tool.

I’m a bit rusty at this, but if i recall correctly you could do something like:

local UpVector = (CFrame.new() * CFrame.Angles(0,0,math.rad(-110))).UpVector

From there you can just tween the ‘GripUp’ property of the Tool where the tween goal of the tool’s ‘GripUp’ is the ‘UpVector’ variable

2 Likes

Yes.

TweenService:Create(obj, tweenInfo, {Orientation = Vector3.new(x, y, z)})
3 Likes
 for i = 0, 10 do
       wait()
       gun.CFrame = gun.CFrame:Lerp(Cframe.Angles(0,0,math.rad(-90)), 0.1)
 end
local TS = game:GetService("TweenService")
local speed = 2 -- Time the tween takes
local object = script.Parent -- Where the object is

local goal = {
 Orientation = Vector3.new(0,0,-110) -- What the end Orientation is
}

local TweenInfo1 = TweenInfo.new(speed, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, 
false, 0)

local Tween = TS:Create(object, TweenInfo1, goal)
Tween:Play()

Here you go :slight_smile:

1 Like

It should be easy, just change the EndGoals dictionary of the tween to say:

Orientation = (The orientation you want to change it to)