Trying to simulate a mouse click in the center of the screen

I am trying to find a way to simulate a mouse click in the center of the screen. This gun tool (Video below) works perfectly on computer, because first person mode sends clicks in the center with a Mouse Instance.

I want to know how I make this gun shoot in the center for mobile devices.
robloxapp-20250209-2123427.wmv (1.4 MB)

It currently isn’t doing that. The bullet is going off of the Mouse.Hit spot when the UI button is clicked (Cause mobile devices send Mouse events like third person)

I already made it so mobile devices cannot click anywhere on the screen to shoot and they have to press that GUI button. I (once again) just need a Vector3 value that is where the center of the screen is pointed it (like the Mouse Instance)

If you want to get the position that is directly in front of the camera like Mouse.Hit.Position, you could use raycasting:

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local cam = workspace.Camera

local params = RaycastParams.new()
params.FilterDescendantsInstances = {char}
params.FilterType = Enum.RaycastFilterType.Exclude

local function getPosFromCam(dist): RaycastResult
  return workspace:Raycast(cam.CFrame.Position, cam.CFrame.LookVector*dist, params)
end