Issue with Tweening CFrame - Global Rotation when needing Local

Hello, I am working on a mounted gun on one of my small boats.

This is an idea of how the welding is setup:

local tempWeld ="Weld")
tempWeld.Parent =
tempWeld.Part0 =
tempWeld.Part1 = script.Parent.offset

local weldToBoat ="Weld")
weldToBoat.Parent = script.Parent.Parent.Parent.ShipStructure.Parts.Model.TurrentLock.lock
weldToBoat.Part0 = weldToBoat.Parent
weldToBoat.Part1 =

Below is the function that is called as W/A/S/D is being held down:

local tweenGoal = {}
local tween = nil
local init = true
function Turrent:Traverse(dir)
	if init then
		init = false
		tweenGoal.C0 = self.Weld.C1 * CFrame.fromEulerAnglesXYZ(0, 0, 0)
	if self.Boat.Alive == false then return end
	if dir == "Up" then
		tweenGoal.C0 = tweenGoal.C0 * CFrame.fromEulerAnglesXYZ(math.rad(2), 0, 0)
	elseif dir == "Down" then
		tweenGoal.C0 = tweenGoal.C0 * CFrame.fromEulerAnglesXYZ(math.rad(-2), 0, 0)
	elseif dir == "Right" then
		tweenGoal.C0 = tweenGoal.C0 * CFrame.fromEulerAnglesXYZ(0, math.rad(-2), 0)
	elseif dir == "Left" then
		tweenGoal.C0 = tweenGoal.C0 * CFrame.fromEulerAnglesXYZ(0, math.rad(2), 0)
	local x, y, z = tweenGoal.C0:toEulerAnglesXYZ()
	x = math.clamp(x, math.rad(-10), math.rad(30))
	y = math.clamp(y, math.rad(-90), math.rad(90))
	tweenGoal.C0 =, tweenGoal.C0.Y, tweenGoal.C0.Z) * CFrame.fromEulerAnglesXYZ(x, y, 0)

	tween = TweenService:Create(self.Weld, self.tweenInfo, tweenGoal)


The issue is it appears to be rotating globally:

How can I fix this so that it does not rotate on what appears to be the Z axis? Also, if anyone has a more efficient way of doing this, I am open to suggestions.

Tl;dr Pitch yaw and roll can be swapped around based on the rotation of part0 and part1, Create new parts for Part0 and Part1 with the same rotation to be welded together, or just make the two parts the same default rotation(up vector up look vector forwards, right vector right)

When welding items, the rotation of the two objects being welded affect how things are handled. It can turn from pitch,yaw,roll to something like yaw,roll,pitch and be completely out of whack. You can either try to guess which combination of pitch yaw and roll it is by testing it, or just create two other correctly and samely rotated parts for the Part0 and Part1 of the weld

1 Like