How can I add an offset to the camera's look vector?

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

  1. What do you want to achieve? Keep it simple and clear!

I’m trying to have a ray (Or gun bullet rather) shoot towards the middle of the player’s screen, which, with a shift lock script, changes position. I’m wondering if it’s possible to add an offset to where the script thinks is the middle of the screen.

Here’s some of my code:

The following is the client code, I’m assuming that’s where I’ll have to add the offset so it can be sent to the server already offset.

UserInputService.InputBegan:Connect(function(input, gameProcessed)
	if tool.Parent.Name == player.Name then
		print("Im in le player")
		local inputType = input.UserInputType
		if inputType == Enum.UserInputType.Touch or inputType == Enum.UserInputType.MouseButton1 then
		if debounce == false or debounce == nil then
			local remoteEvent = script.Parent.Remotes:WaitForChild("~~RE Here~~")

			-- Fire the remote event
				--local camera = workspace.CurrentCamera
				--local unitRay = camera:ScreenPointToRay(100, 100)
				local camera = workspace.CurrentCamera
			--	local viewportPoint = camera.ViewportSize / 2
				local camlookvector = camera.CFrame.LookVector --camera:ViewportPointToRay(viewportPoint.X, viewportPoint.Y, 0)

			--	local Players = game:GetService("Players")
				--local localPlayer = Players.LocalPlayer
				--local mouse = localPlayer:GetMouse()
				--local unitRayDirection = mouse.UnitRay.Direction
				--local mouseHitDirection = mouse.Hit.lookVector

				local ShootFunction = script.Parent.Remotes:WaitForChild("~~RE Here~~")
			--	if bulletsleft > 0 then
					local be = script.Parent.Remotes:WaitForChild("~~RE Here~~")
					-- Invoke the function
				local Damage, BulletAmt, MagAmt = ShootFunction:InvokeServer(camlookvector)
					print("damage done,", Damage, "Bullets Left,", BulletAmt, "Mags left,", MagAmt)
					bulletsleft = BulletAmt
				--elseif bulletsleft == 0 then
				--	warn("NO MORE")

			debounce = true
			debounce = false
			print("Still waiting")


I am using this script for an in-game shift lock effect, it’s not roblox’s but one that I used off of dev forum

--Local script in StarterPlayerCharacter
local plr = game:GetService("Players").LocalPlayer
local mouse = plr:GetMouse()
local char = plr.Character
local hum = char:WaitForChild("Humanoid")
local rotation ="BodyGyro") --Create a new body gyro.
rotation.P = 1000000 --Increase the power
rotation.Parent = hum.RootPart --Parent it to the HumanoidRootPart
local conn -- connection variable
function shiftLock(active) --Toggle shift.lock function
	if active then
		hum.CameraOffset =,0.5,0) -- I assume this is about the right camera offset.
		rotation.MaxTorque =, math.huge, 0) --Max the power on the Y axis
		conn = game:GetService("RunService").RenderStepped:Connect(function()
			rotation.CFrame = mouse.Origin
			game:GetService("UserInputService").MouseBehavior = Enum.MouseBehavior.LockCenter
		end) --Set the mouse to center every frame.
		hum.CameraOffset =,0,0) --Move the camera back to normal.
		rotation.MaxTorque =, 0, 0) --Clear the torque on the HumanoidRootPart
		if conn then conn:Disconnect() end -- Allow mouse to move freely.
--shiftLock(true) -- Enable shift lock
--print("Shift lock turned on!")
shiftLock(false) --Toggle off shift Lock

I first thought of multiplying the camlookvector by the offset (hum.CameraOffset =,0.5,0))

If anyone has advice please let me know asap, thanks and have a great day!