How do I make the turret head turn to the mouse location?

I am in the process of making the turret head of my warship to turn and face the mouse position using body gyro (for the smooth following action when you move your mouse) and a hinge for rotation.? (Idk if the hinge is part of the problem or not)

The issue is that I have no idea how to do it properly and I am stuck.

I have tried using the methods on Youtube and DevForum like bodygyro.CFrame =, part.CFrame.Y, mouse.Hit.Position.Z)
but with no success…

the turret head is a union and Idk if that will affect the turning.

Any help is appreciated! I will provide as much info as I can!

1 Like

Hello! You’re doing wrong CFrame you CFrame shoud look like this

local Pos =,mouse.Hit.Y,mouse.Hit.Z),Pos)

I hope it will works!

I will try it right now! 3000000

the union is spinning by itself with body gyro and hinge

1 Like

Finally got it to work! Big thanks to @EsplishData for showing me my mistakes. For any future viewers, here is what I did:

local invisBox = game.Workspace.testHeadmodel.Invisbox
local mouse = game.Players.LocalPlayer:GetMouse()
local bodygyro = invisBox.BodyGyro

while wait() do
bodygyro.CFrame = ,, invisBox.Position.Y, mouse.Hit.Position.Z) )
1 Like