Hello there. I have code that is supposed to change both the Left Shoulder and Right Shoulder by the camera in a viewmodel-like fashion. The reason for this inefficiency is that my game can be both in first-person and third-person however using a custom viewmodel would cause bad inaccuracies in gameplay. Here is my code:
local RS = game:GetService("RunService")
RS.RenderStepped:Connect(function()
local Character = game.Players.LocalPlayer.Character
local Head = Character:WaitForChild("Head")
local Torso = Character:FindFirstChild("Torso")
local LeftShoulder = Torso:FindFirstChild("Left Shoulder")
local RightShoulder = Torso:FindFirstChild("Right Shoulder")
Character:WaitForChild("Left Arm", 20).LocalTransparencyModifier = 0
Character:WaitForChild("Right Arm", 20).LocalTransparencyModifier = 0
if Head then
Head:GetPropertyChangedSignal("LocalTransparencyModifier"):Connect(function()
if Head.LocalTransparencyModifier == 0 then
if LeftShoulder then
LeftShoulder.C0 = workspace.CurrentCamera.CFrame * CFrame.new(0, 0, -5)
end
if RightShoulder then
RightShoulder.C0 = workspace.CurrentCamera.CFrame * CFrame.new(0, 0, -5)
end
else
LeftShoulder.C0 = Torso.CFrame + Vector3.new(1.5, 0, 0)
RightShoulder.C0 = Torso.CFrame + Vector3.new(-1.5, 0, 0)
end
end)
end
end)
Any kind of help would be appreciated, thanks!