You could get the location of the mouse though Player:GetMouse and set the CFrame of the gun accordingly, for the fire key you could use UserInputService to know when the player press the F key.
contextActionService:BindAction("Fire", function()
--shoot the turret
end, false, Enum.KeyCode.F)
To shoot the turret.
Unfortunately we cannot just dump this code on you as a lot of this is fairly advanced and depend on how you have set everything up but I hope this helps.