Need help with an Artillery System!

Hello everyone! I’ll cut short, I’ve been making an artillery system, everything works fine, except the movement system. I’m using a Pivot system to move the models. The main model moves perfectly fine, however the artillery barrel is slowly rotating inversely. If I rotate it by 180 degrees, the barrel rotation is completely inversed. Here’s what I mean.

0 Degrees

image

180 Degrees

image

As I slowly turn the artillery, it slowly inverses, I’ve tried messing with the code and pivots, but nothing really works. Any help is greatly appreciated!

Useful stuff:

Barrel Pivots
image

Main Code

--// shell details

local force = 1000
local upforce = 250

--// recoil stuff

local recoil_dist = 2.5
local recoil_time = 0.5

--// turning stuff

local turn_speed = 0.1
local turn_power = 5

local info = TweenInfo.new(recoil_time, Enum.EasingStyle.Circular, Enum.EasingDirection.Out, 0, true)



move.OnServerEvent:Connect(function(player, dir)
	
	if shot_status == true then return end
	
	if dir == "left" then
		howitzer.Barrel:PivotTo(howitzer.Barrel:GetPivot()*CFrame.Angles(0,math.rad(turn_power),0))
		howitzer.Shield:PivotTo(howitzer.Shield:GetPivot()*CFrame.Angles(0,math.rad(turn_power),0))
	elseif dir == "right" then
		howitzer.Barrel:PivotTo(howitzer.Barrel:GetPivot()*CFrame.Angles(0,math.rad(-turn_power),0))
		howitzer.Shield:PivotTo(howitzer.Shield:GetPivot()*CFrame.Angles(0,math.rad(-turn_power),0))
	end
end)
2 Likes

Not sure if this will work, but in all of the math.rad(), subtract turnpower from 180. If the turnpower is negative, add it to 180.

image

This doesn’t seem to work

I’m not sure if :GetPivot rotates wierdly, again, I don’t know much about GetPivot, so take my response with a massive grain of salt. Try using a primary part for the cannon. If it doesn’t work, sorry in advance.

The last two need to be this:
180+turnpower

image

Seems to not work either