Attachment not looking at a part direction

Hello!
So I’m trying to make a game where you can control your hands to propulse in air using inverse kinetics (IK).
While making it, I encountered a problem:
When I click with my mouse, the attachment in the humanoid root part which is supposed to watch in the direction of the mouse 3D location, doesn’t look at it and takes a weird orientation.
Here is a video of what is happening:

Here is the part of the script with the attachment (Server side):

remote2.OnServerEvent:Connect(function(plr,state,mult,mouseLoc) -- fired with a "while true do" loop from the client side until he releases the mouse button 1.
	local char = plr.Character
	local hrp = plr.Character.PrimaryPart
	local rightLower = char.RightLowerArm
	local boost = rightLower.BoostPart
	local mass = getMass(char)
	local att = hrp:FindFirstChild("Attachment")
	if state == "Start" then
		att.CFrame = CFrame.lookAt(att.Position, mouseLoc) -- which is the mouse location
	elseif state == "Stop" then
		if mult == 0 then
			
		end
	end
end)

Is there any ways to make that works ? I’m pretty sure it’s with the attachment orientation which turns to 180 to -180.

Any helps appreciated!

Be aware of the fact that you’re modifying the CFrame property of the attachment which is an offset from the part’s position, same with position, you might wanna use WorldPosition and WorldCFrame instead.
EDIT: Taking a closer look at the code, that’s the issue, you’re basically checking from pos 0 0 0 of the world to wherever you’re pointing, and so it’s giving you that orientation instead of the orientation you desired.

2 Likes

Thanks for the explaination! It’s working perfectly!

EDIT: now I only need it to make the attachment’s lookVector watch at the part.

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