How do I lerp or tween something with the same effect as CFrame.lookat except with tweening?

I want to make a part lerp or tween to look at something instead of instantly looking at something so that it looks more natural. Since I don’t have any experience with lerp or tween, how do I do this?

I would recommend watching this video, hopefully it helps. How to use BodyGyros in Roblox Studio - YouTube

I want to use a different way exactly because I was using bodygyros and they didn’t fit my goal well enough.

Oh, Sorry I don’t believe I can help. I’ve personally never attempted this myself so I’m not sure how to go about it. Hopefully someone with more experience will help you.

Hmm well there are a few good ways to do it actually only three. Forces BodyMovers or CFraming. what is your goal?

Hey! Maybe take a look at the API-Reference of the TweenService | Roblox Creator Documentation. This is very detailed and has some code examples at the end of the page.

Cheers

I want to do it with CFraming.

Okay so lets make say there is a part that is facing forward in world space.

If we want it to look at the point 5,6,7 We can simply do

Part.CFrame = CFrame.lookAt(Part.Position, Vector3.new(5,6,7))

What happens if we want to move outpart and keep it looking at the point?

Due to the nature of linear movement it is certain that the tweening CFrame will always look at the point so long as the start and end CFrames are

local newPos = Vector3.new(20,20,20)

local Goal = {}
Goal.CFrame = CFrame.LookAt(newPos, Vector3.new(5,6,7)
local Tween = TweenService:Create(Part,TweenInformation,Goal):Play()

In other words basically you do not need to worry you can simply just sett the tween goal to look at the point you want to keep looking at.

The will work so long as it moves in a straight line…which tweening does.

What do I do about tween info?

Well, you can do anything you want with it. It doesn’t really matter.Here is the documentation on it.TweenInfo | Roblox Creator Documentation

Ok, I tested this. It worked! Thanks to everyone who tried to help!

1 Like