How to Tween rotation so an instance looks at a player

            local direction = (targ.Parent.Head.Position - script.Parent.Head.Position).Unit
			local cframe = CFrame.new(script.Parent.HumanoidRootPart.Position,direction)
			local x, y, z = cframe:ToEulerAnglesYXZ()
			local rotation = Vector3.new(x,0,0)
			local goal = {Orientation = rotation}
			tweenserv:Create(script.Parent.HumanoidRootPart,TweenInfo.new(2),goal):Play()

This is the code I have to do it, but it literally makes the NPCs fly up into the sky.

1 Like

Here’s what happens.

Tween the CFrame rather than just the orientation.

CFrame.new takes two values, a vector and a lookAt.

Force them to look at your HumanoidRootPart or your head. Either should be fine.

EDIT: Roblox allows you to use “lookAt” more efficiently using CFrame.lookAt, which allows you to do what CFrame.new previously accomplished, just better.

Try that method instead.

Ohhhh. Thanks! I’ll try this and let you know if it works.

It worked! Thanks so much!! <3

1 Like

No worries! Glad I could help.