Part "Randomly" Moves To Center Of Baseplate

So I’m trying to make a part rotate using a joystick control that I made. The rotation part works fine and is accurate however when rotating the hinge (the part that rotates) moves to the center of the baseplate as can be seen in the video below. The forcefield also spawns in the center of the baseplate and not where the player does, so I’m not sure if that correlates to the problem.
https://gyazo.com/74288635a0c675a548decd10deb7ef81

No parts of the player model is even close to the forcefield so I’m not sure why the forcefield is spawning there.

Here’s the script that rotates the hinge, but I’m honestly very confused as to what could be going wrong.

Hinge.CFrame = CFrame.Angles(0, math.rad(Frame.Rotation * -1), 0)
HingeBodyGyro.CFrame = Hinge.CFrame
ObjectBodyGygro.CFrame = Hinge.CFrame
end

If you have any ideas, suggestions, comments or questions please leave a reply.

Thanks for reading and have a great day!

The problem is because of this line:

 Hinge.CFrame = CFrame.Angles(0, math.rad(Frame.Rotation * -1), 0)

You are setting the Hinge.CFrame to be just a new CFrame.Angles. So this will put it at the coordinates 0,0,0 but with the angle offset you gave. If you want it to be in a different position, you need to also multiply by the coordinates u want to offset it by.

So if you want the hinge to be at the coordinates Vector3.new(10,0,10) then you would do:

Hinge.CFrame = CFrame.new(Vector3.new(10,0,10)) * CFrame.Angles(...) -- put whatever you had

Also the order of multiplication in the CFrame matters, if that didn’t work for you, try rearranging the multiplication.

2 Likes