How to fire Bullets aimed at center

I’m writing a script for mobile
On PC, the bullet fires depending on the position of the mouse
On mobile, i making it designed to be fired in a mouse center.
But I don’t know. I use my mouse to press the walking button on my mobile
It fires in the direction of the walking button. To solve this problem
I really put it up here in the last way.

Here’s the local script.

Tool.Activated:Connect(function(input, gameHandledEvent)
if Mouse ~= nil and IsMouseDown then
	wait(0.5)
		local uis = game:GetService("UserInputService")
		local tru = uis.TouchEnabled
		if tru == true then
			UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
			wait(0.1)
			MouseEvent:FireServer(Mouse.Hit.Position)
		else
			MouseEvent:FireServer(Mouse.Hit.Position)
			print(Mouse.Hit.Position)
		end
	
	delay(1, function()
		IsMouseDown = true
	end)
end
end)

And it’s part of the server script.

function Fire(direction)
	-- Called when we want to fire the gun.
	if Tool.Parent:IsA("Backpack") then return end -- Can't fire if it's not equipped.
	-- Note: Above isn't in the event as it will prevent the CanFire value from being set as needed.
      local BULLET_SPEED = 300	
	-- UPD. 11 JUNE 2019 - Add support for random angles.
	local directionalCF = CFrame.new(Vector3.new(), direction)
	print(directionalCF)
	-- Now, we can use CFrame orientation to our advantage.
	-- Overwrite the existing Direction value.
local direction = directionalCF.LookVector

	-- UPDATE V6: Proper bullet velocity!
	-- IF YOU DON'T WANT YOUR BULLETS MOVING WITH YOUR CHARACTER, REMOVE THE THREE LINES OF CODE BELOW THIS COMMENT.
	-- Requested by https://www.roblox.com/users/898618/profile/
	-- We need to make sure the bullet inherits the velocity of the gun as it fires, just like in real life.
	local humanoidRootPart = Tool.Parent:WaitForChild("HumanoidRootPart", 1)	-- Add a timeout to this.
	local myMovementSpeed = humanoidRootPart.Velocity							-- To do: It may be better to get this value on the clientside since the server will see this value differently due to ping and such.
	local modifiedBulletSpeed = (direction * BULLET_SPEED)-- + myMovementSpeed	-- We multiply our direction unit by the bullet speed. This creates a Vector3 version of the bullet's velocity at the given speed. We then add MyMovementSpeed to add our body's motion to the velocity.
    
	if PIERCE_DEMO then
		CastBehavior.CanPierceFunction = CanRayPierce
	end

	local simBullet = Caster:Fire(FirePointObject.WorldPosition, direction, modifiedBulletSpeed, CastBehavior)
	-- Optionally use some methods on simBullet here if applicable.

	-- Play the sound
	PlayFireSound()
end

I will let you know if I need any more information please help me… :disappointed_relieved:

Using RayCast, you can cast a ray from the center of the camera

example

local camera = workspace.CurrentCamera
local cameraCF = camera.CFrame

local length = 1000
local params = RaycastParams.new()

local raycastResult = workspace:Raycast(cameraCF.Position, cameraCF.LookVector * length, params)

Hi I’m using my idiot head, how can a client send the CFrame of the camera?
If send it to the script described below, an error will appear like the picture below.
Can you give me more feedback?

dsa

script:

UserInputService.InputBegan:Connect(function (input, gameHandledEvent)
	if input.KeyCode == Enum.KeyCode.E and Mouse ~= nil and IsMouseDown then
		IsMouseDown = false
		MouseEvent:FireServer(Vector3.new(cameraCF))
		delay(1, function()
			IsMouseDown = true
		end)
	end
end)