How to create a working battleship gun

You can write your topic however you want, but you need to answer these questions:

  1. I’m looking to achieve a battleship gun that aim at whatever you click at and fires when the F key is pressed

  2. I’m not too good at scripting and i’m just very confused on how I can make a working battleship gun

  3. I’ve tried looking for tutorials everywhere but haven’t really found any help

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.

In a localscript you can do

local contextActionService = game:GetService("ContextActionService")

local mouse = game.Players.LocalPlayer:GetMouse()

To get the mouse and services and you can use

mouse.Button1Down:Connect(function()
	turret.CFrame = CFrame.lookAt(turret.Position, mouse.Hit.Position)
end)

To look at the mouse on click and use

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.

BattleshipGun:PivotTo(CFrame.lookAt(BattleshipGun:GetPivot().Position, Mouse.Hit.Position))