Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How would I force player to smoothly turn at part?

function lookAt2(chr,target)
	if chr.PrimaryPart then
		local chrPos=chr.PrimaryPart.Position
		local tPos=target.Position
		local newCF=CFrame.new(chrPos,tPos)
		chr:SetPrimaryPartCFrame(newCF)
	end
end

lookAt2(char,v.HumanoidRootPart)

basically I'm using this function in order to make player rotate to certain target but its all choppy and not smooth so I was wondering how I could make it, I was looking everywhere and only solution was using tween service and CFrame.Angles(0,math.rad(n),0) but I need it to rotate to a certain part and I don't know how to do that with tween service and .Angles, anyone knows how I can make it work?

2 answers

✓ Accepted answer

You should use TweenService.

local function LookAt(A, B)
    if not A.PrimaryPart then return end
    game:GetService('TweenService'):Create(A.PrimaryPart, TweenInfo.new(1), {CFrame = CFrame.new(A.PrimaryPart.Posirion, b.Position)}):Play();
end

LookAt(char, v.HumanoidRootPart);

Let me know if this helps.

You should use TweenService to smoothly change values.

TweenService API

EDIT: Just read your question more throughly, you should use a BodyGyro inside of HumanoidRootPart to smoothly rotate the character at the desired force;

BodyGyro API

2 comments

0

it doesn't quiet helps me because I don't know how to use it that way, I can't change it smoothly using tweenservice because it uses setprimarypartcframe

0

Edited my answer.

This discussion is preserved as it was. New answers, comments, and votes are closed.