Help with orientation

This is a support category for asking questions about how to get something done on the Roblox websites or how to do something on Roblox applications such as Roblox Studio.

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want the turrets orientation to stay the same while moving.
  2. What is the issue? Include screenshots / videos if possible!
    When turret moves it uses the calculation of 2 hinges and when one moves it affects another. Basically when its meant to keep the up orientation it tps to the same orientation as the other hinge.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have tried messing around with the numbers, but couldn’t find a way to make the math math
    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!
    heres the bit of the orientation thats confusing:

if parttomove == ship:WaitForChild(“Model”).gun2 then
–local otherpart = ship:WaitForChild(“Model”):WaitForChild(“gun2.001”)
local otherpart = ship:WaitForChild(“TurretHingeY”)
local TurretX = ship:WaitForChild(“TurretHingeX”)
local rot = otherpart.CFrame * movement --+ otherpart.CFrame.LookVector * 1
otherpart.CFrame = rot
local turretgun = ship:WaitForChild(“Model”):WaitForChild(“gun2.001”)
–print((otherpart.CFrame.X * movement))
–turretgun.CFrame = turretgun.CFrame * (otherpart.CFrame.X * movement)
local NormalYForX = TurretX.Position.Y
local xrotation = TurretX.Orientation.X
local regrotation = turretgun.Orientation
turretgun.CFrame = rot
turretgun.Orientation = Vector3.new(turretgun.Orientation.X, regrotation.Y, turretgun.Orientation.Z)
print(turretgun.CFrame)
local turretxrot = TurretX.CFrame * movement – lets see how this works
TurretX.CFrame = turretxrot-- + Vector3.new(0,1,0)
–TurretX.CFrame = CFrame.fromEulerAnglesXYZ(TurretX.CFrame.Position.X, TurretX.CFrame.Position.Y, TurretX.CFrame.Position.Z)
print(xrotation)
–TurretX.Orientation = Vector3.new(xrotation, 0, 0)
local part = Instance.new(“Part”) – just for experimenting
else
local TurretY = ship:WaitForChild(“TurretHingeX”)
–local otherpart = ship:WaitForChild(“TurretHingeX”)
local rot = TurretY.CFrame * movement --+ otherpart.CFrame.LookVector * 1
–parttomove.CFrame = parttomove.CFrame * movement – Apply the rotation to the part then
parttomove.CFrame = rot
TurretY.CFrame = rot
–parttomove.CFrame = parttomove.CFrame.LookVector * 1.3
print(movement)
–otherpart.CFrame = otherpart.CFrame * movement
end

Roblox has a Constraint that may help: