Shoulder Camera do not look At crosshair

IF Shoulder Camera is turned on it should look at mouse Cursor Position but now it look every time at the same position

game:GetService("RunService").RenderStepped:Connect(function()

	uis.MouseBehavior = Enum.MouseBehavior.LockCenter


	local startCFrame = CFrame.new((hrp.CFrame.Position)) * CFrame.Angles(0, math.rad(x), 0) * CFrame.Angles(math.rad(y), 0, 0)
	local cameraCFrame = startCFrame:ToWorldSpace(CFrame.new(offset.X, offset.Y, offset.Z))
	local cameraDirection = startCFrame:ToWorldSpace(CFrame.new(offset.X, offset.Y, -10000))

	camera.CFrame = CFrame.new(cameraCFrame.Position, cameraDirection.Position)
end)

How do i Fix that?

Why do you use object.CFrame.Position? You don’t need to add .Position for the CFrame.

:ToWorldSpace is creating a Vector3 thats why i am using .Position

1 Like

Can anybody Help? I still dont know how to fix it. :frowning:

Are you trying to make the character point towards the pointer?

i just want if the the camera is enable it schould start with direction from the old camera

So the character points towards the camera?

thats my problem look
https://streamable.com/8p5dcw
the camera is always directing this one point

here is the code of the shoulder camera

local uis = game:GetService("UserInputService")


local camera = workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Scriptable


local char = script.Parent


local humanoid = char:WaitForChild("Humanoid")
humanoid.AutoRotate = true

local function getPlayerFromCharacter(character)
	for _, player in pairs(game:GetService("Players"):GetPlayers()) do
		if player.Character == character then
			return player
		end
	end
end

local player = getPlayerFromCharacter(char)
local mouse = player:GetMouse()
local hrp = char:WaitForChild("HumanoidRootPart")


local x = 0
local y = 0


local offset = Vector3.new(3, 3, 10)


uis.InputChanged:Connect(function(input, processed)

	if processed then return end

	if input.UserInputType == Enum.UserInputType.MouseMovement then

		x = x - input.Delta.X

		y = math.clamp(y - input.Delta.Y*0.4, -75, 75)


		hrp.CFrame = hrp.CFrame * CFrame.Angles(0, math.rad(-input.Delta.X), 0)
	end
end)


game:GetService("RunService").RenderStepped:Connect(function()

uis.MouseBehavior = Enum.MouseBehavior.LockCenter


	local startCFrame = CFrame.new((hrp.CFrame.Position)) * CFrame.Angles(0, math.rad(x), 0) * CFrame.Angles(math.rad(y), 0, 0)
	local cameraCFrame = startCFrame:ToWorldSpace(CFrame.new(offset.X, offset.Y, offset.Z))
	local cameraDirection = startCFrame:ToWorldSpace(CFrame.new(offset.X, offset.Y, -10000))
	
	
	camera.CFrame = CFrame.new(cameraCFrame.Position, cameraDirection.Position)
end)

To make the character point towards the camera, use this code:

game:GetService("RunService").RenderStepped:Connect(function()
   uis.MouseBehavior = Enum.MouseBehavior.LockCenter;
   hrp.CFrame = CFrame.new(hrp.Position, hrp.Position + Vector3.new(camera.CFrame.LookVector.X,0,camera.CFrame.LookVector.Z));
end);

I found a similar one on a different post a while ago, I adjusted it to be a little cleaner and shorter. It works pretty well. I also adjusted it to fit your variables names.

1 Like

sholud i delete my renderStepped and place yours insted or what?
if yes
its works but the shoulder camera is not there and has no follow on char