Rotating motor6D (up and down) to face a part position

Hello there!

I’m stuck onto a small problem which i’m having trouble to fix it.
I searched solutions multiple time on the forum but i didn’t found what i’m exactly looking for.

What i want is to rotate the "Waist" motor6D from the "UpperTorso" of players character to make it facing to the enemie npc "HumanoidRootPart" position.
I want to rotate the waist only on the X axis, to make it Up and Down.

I tried some things like:

Waist.C0 = CFrame.lookAt(Waist.C0, Vector3.new(EnemieRoot.Position.X, Waist.C0.Y, Waist.C0.Z))
-------------------
Waist.C0 = CFrame.lookAt(UpperTorso.Position, Vector3.new(EnemieRoot.Position.X, UpperTorso.Position.Y, UpperTorso.Position.Z))
-------------------
Waist.C0 = CFrame.Angles(EnemieRoot.Position.Y, 0, 0)
-------------------
Waist.C0 = CFrame.FromOrientation(EnemieRoot.Position.Y, 0, 0)

And more… i tried many possibilities
Help would be apreciated!

Here is some images of what i’m looking for:

This is how it is actualy

This is how i want it to be

1 Like

This should help you,

Thank for your help!

Found the solution on this post, which is related to the post you gived me ^^

So i edited the script a little bit and… here is the solution (in case if someone also need it):

--Getting variables
self.Waist = self.Character:FindFirstChild("Waist", true)
self.UpperTorso = self.Character:FindFirstChild("UpperTorso", true)

--Running code with RenderStepped
if EnemieRoot and Waist and UpperTorso then	
	local Distance = (UpperTorso.CFrame.p - EnemieRoot.Position).magnitude
	local Difference = UpperTorso.CFrame.Y - EnemieRoot.Position.Y
			
	Waist.C0 = CFrame.Angles(-(math.atan(Difference / Distance) * 0.75), 0, 0)
else
	Waist.C0 = CFrame.Angles(0, 0, 0)
end

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.