How to lerp this?

function onTouched(hit)

if hit.Name ~= “Part” then return end

game.Workspace.CameraPos.Position = Vector3.new(-257.015, 150.00, -272.06)

end

script.Parent.Touched:connect(onTouched)

You should be using TweenService to animate the part since you’re modifying the Position property of the part and not the CFrame property. Here’s an example:

local TweenService = game:GetService("TweenService")

local TIME = 1 
local ENDPOS = Vector3.new(-257.015, 150.00, -272.06)

-- tweenservice.create arguments:: part of properties to be modified, tweeninfo, and table of properties to be modified

TweenService:Create(workspace.CameraPos, TweenInfo.new(TIME), {
	Position = ENDPOS
}):Play()

But if you’re specifically looking to lerp the camera, you can use the Lerp method of the CFrame like so:

Note that the Lerp method (short for linear interpolation) only applies to CFrames so you’re going to be modifying the CFrame property of the part instead of the Position property which is a Vector3.

local ENDPOS = CFrame.new(Vector3.new(-257.015, 150.00, -272.06))

-- lerp arguments: end goal cframe, fraction to interpolate original cframe and goal cframe by

for i = 0, 1, 0.1 do
	workspace.CurrentCamera.CFrame = workspace.CurrentCamera.CFrame:Lerp(ENDPOS, i)
	wait()
end
3 Likes

Thanks but,what about using part?

Oh sorry, I misread your original script. You can replace workspace.CurrentCamera with workspace.CameraPos and it’ll function the same. Let me edit the original script for you.

1 Like

I recommend and “one up” @metryy’s method, but as a reminder when posting in scripting support try to format things correctly (unless you are on mobile then its quite difficult) Shortcut Keys and Formatting

2 Likes

how???(30 characters sorry)

I edited the script I posted. Also, to properly format your code, put 4 spaces before each line to give it it’s own code block with syntax highlighting like so:

1 Like

You can tween the part like this:

local Child = script.Parent:GetChildren()
local ts = game:GetService("TweenService")
local ti = TweenInfo.new(3, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
local part = the part tweened


local Tween = ts:Create(part, ti, {Position = Vector3.new(The disired position)})
Tween:Play()
1 Like