How to "tween" this?

I wanna tween a offset value that is a CFrame, but whenever i throw

for i = 0, 1, 0.01 do
	offset:Lerp(CFrame.new(-1.5, -4.6, 2), i)
	task.wait()
end

It doesnt do anything. Any help is appreciatted. To clarify what im trying to achieve:
I wana smooth that out, so i wanna set the offset to CFrame.new(-1.5, -4.6, 2) but smoothly

Do you want to use :lerp specifically or would TweenService be allowed?

In the case where TweenService is allowed to be used with your script, we can do:

local TweenService = game:GetService("TweenService");
local tweenInfo = TweenInfo.new(
1,
Enum.EasingStyle.Linear,
enum.EasingDirection.In,
0
);

local Tween = TweenService:Create(OBJECT_HERE, tweenInfo, {CFrame = CFrame.new(-1.5, -4.6, 2)})
Tween:Play();

I’m not sure if this would work, but we’ll try it and see.

You need to assign the lerped CFrame to the CFrame of an object for it to update.
Set offset:Lerp(CFrame.new(-1.5, -4.6, 2), i) to the CFrame of the object you want to set.

for i = 0, 1, 0.01 do
    object.CFrame = object.CFrame:Lerp(CFrame.new(-1.5, -4.6, 2), i)
	task.wait()
end

As @GIassWindows said, TweenService would be better to use.

This is going off where it is now then tweening to the offsets. Speed here is set to 2. Try whatever works best for you.

local TweenService = game:GetService("TweenService")
local part = workspace.Part -- your part

local initialCFrame = part.CFrame
local targetCFrame = CFrame.new(-1.5, -4.6, 2)

local goal = {CFrame = targetCFrame}
local tweenInfo = TweenInfo.new(2, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
local tween = TweenService:Create(part, tweenInfo, goal)
tween:Play()

Can mess around with these also: Enum.EasingStyle.Quad, Enum.EasingDirection.Out
maybe … Enum.EasingStyle.Linear, Enum.EasingDirection.InOut or just Enum.EasingStyle.Linear

1 Like

Problem is, is that it isnt an object, ik how to use tweenservice.
The “offset” is just a variable that holds a CFrame.

local offset = CFrame.new(-.4, -4.4, -.2)
local ogOffset = offset

To get you an idea of what im trying to achieve: I want this to be smooth: https://gyazo.com/d66a586baafb3e9351c63a99503b3e94 (The aiming)

As tweenservice needs an instance object, i cant really use tweenservice. Or i would need to make it an number value instead i think.

The CFrame value instance worked. My apologies for wasting yall time for nothing. I didnt know a “CFrame value” instance even existed. Sorry.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.