You can write your topic however you want, but you need to answer these questions:
- What do you want to achieve? Keep it simple and clear!
I want my NPC’s torso to face towards the target’s torso.
- What is the issue? Include screenshots / videos if possible!
R6 Head and Torso Look at mouse
I got the code from him and modified it a bit, but the torso does not face the target properly.
- **What solutions have you tried so far? ** Did you look for solutions on the Developer Hub?
I have searched everywhere on the forums about this problem, but it seems that nobody is having these problems, or it just has not been addressed.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
I’m currently using a while do loop wait(0.1) to aim at the target.
function aim(target)
while true do wait(0.1)
if Neck and Waist then
local Point = target.Parent.HumanoidRootPart.Position
local TorsoLookVector = myTorso.CFrame.lookVector
local HeadPosition = Head.CFrame.p
local Distance = (Head.CFrame.p - Point).magnitude
local Difference = Head.CFrame.Y - Point.Y
local xAxisWaistRotation = -(math.atan(Difference / Distance) * 0.5)
local yAxisWaistRotation = (((HeadPosition - Point).Unit):Cross(TorsoLookVector)).Y * 0.5
local rotationWaistCFrame = CFrame.Angles(xAxisWaistRotation, yAxisWaistRotation, 0)
local goalWaistCFrame = rotationWaistCFrame*WaistOriginC0
Waist.C0 = Waist.C0:lerp(goalWaistCFrame, 0.1).Rotation + WaistOriginC0.Position
local currentLegCounterCFrame = Waist.C0*WaistOriginC0:Inverse()
local legsCounterCFrame = currentLegCounterCFrame:Inverse()
end
end
end
Any help will be appreciated! Thank you for reading my forum!