How can I make a Barrel and Base move relative to the mouse?

So I am attempting to make the Barrel and Base both move towards the direction of my mouse.

8bfd7a74b2fc6348698ff4fca174b812
I want these two parts seen in the picture to go in a full 360 degree rotation and move the way the Mouse is pointing towards.

Please tell me if my descriptions are too vague, it’s difficult to explain and not make it confusing.

I’ve tried looking all over the DevForum for threads similar but I found none. Help is appreciated!

1 Like

Are they connected to each other at all? and what’s your method of locomotion?

either way, you’re looking at either CFrame.new(Pos,Lookat) OR using trig

something like

V1 = InitiallookVector --this is defined when the turret is placed/loaded
V2 = (Turret.CFrame.p-Mouse.Hit.p).unit --returns a vector pointing to where the mouse is pointing, consider multiplying by vector 1,0,1 to cut Y axis from calculations

Angle = math.acos(V1:Dot(V2)) -- returns angle difference between the two vectors in Radians, apply locomotion method of choice

Sorry for the late response. Yes, the two parts are connected via Welds.