Why won't my camera change position?

I’m trying to make a custom camera, so every frame the players camera cframe is a part welded to the player cframe, but it doesn’t work well.

Local script in SCS:

local Players = game:GetService("Players")
local RunService = game:GetService("RunService")

local camera = workspace.CurrentCamera

local plr = Players.LocalPlayer
local char = plr.Character
local mouse = plr:GetMouse()

local CameraPos = char:FindFirstChild("CameraPos")

local armOffset = char.Torso.CFrame:Inverse() * char["Right Arm"].CFrame + Vector3.new(0, 0, -.75)
local armOffset2 = char.Torso.CFrame:Inverse() * char["Left Arm"].CFrame + Vector3.new(0, 0, -.75)

local armWeld = Instance.new("Weld")
armWeld.Part0 = char.Torso
armWeld.Part1 = char["Right Arm"]
armWeld.Parent = char

local armWeld2 = Instance.new("Weld")
armWeld2.Part0 = char.Torso
armWeld2.Part1 = char["Left Arm"]
armWeld2.Parent = char

RunService.Heartbeat:Connect(function()
	camera.CameraType = Enum.CameraType.Custom
	camera.CFrame = CameraPos.CFrame
	local cframe = CFrame.new(char.Torso.Position, mouse.Hit.Position) * CFrame.Angles(math.pi/2, 0, 0)
	armWeld.C0 = armOffset * char.Torso.CFrame:toObjectSpace(cframe)
	local cframe2 = CFrame.new(char.Torso.Position, mouse.Hit.Position) * CFrame.Angles(math.pi/2, 0, 0)
	armWeld2.C0 = armOffset2 * char.Torso.CFrame:toObjectSpace(cframe2)
end)

Please help me.

So, I think I may have figured out the problem and I’m not even sober yet lol but anyways, tell me if this works

local Players = game:GetService("Players")
local RunService = game:GetService("RunService")

local camera = workspace.CurrentCamera

local plr = Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local mouse = plr:GetMouse()

local CameraPos = char:FindFirstChild("CameraPos") or Instance.new("Part")
CameraPos.Name = "CameraPos"
CameraPos.Anchored = true
CameraPos.CanCollide = false
CameraPos.Transparency = 1
CameraPos.Size = Vector3.new(0.1, 0.1, 0.1)
CameraPos.Parent = char

local armOffset = CFrame.new(0.5, 0, -1.5) -- Adjust these offsets as needed
local armOffset2 = CFrame.new(-0.5, 0, -1.5) -- Adjust these offsets as needed

local armWeld = Instance.new("Weld")
armWeld.Part0 = char.Torso
armWeld.Part1 = char["Right Arm"]
armWeld.C0 = armOffset
armWeld.Parent = char["Right Arm"]

local armWeld2 = Instance.new("Weld")
armWeld2.Part0 = char.Torso
armWeld2.Part1 = char["Left Arm"]
armWeld2.C0 = armOffset2
armWeld2.Parent = char["Left Arm"]

RunService.Heartbeat:Connect(function()
    camera.CameraType = Enum.CameraType.Custom
    camera.CFrame = CameraPos.CFrame
    local lookAt = char.Torso.Position + mouse.Hit.Position - char.Torso.Position
    local cframe = CFrame.new(char.Torso.Position, lookAt) * CFrame.Angles(math.pi/2, 0, 0)
    armWeld.C0 = armOffset:Inverse() * cframe
    armWeld2.C0 = armOffset2:Inverse() * cframe
end)

how about don’t weld the Right Arm or Left Arm to the torso? Instead weld the actual CameraPos to the torso? If you’re trying to look from the perspective of the shoulder.
And in that case, you can’t have both welds active at the same time since they will have conflicting positioning.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.