Character arms follow camera

Try this code, it changes the motor6d’s c0 and c1 according to the camera’s Y axis. Before hand you have to put a remote event in the replicated storage and call it whatever.

Local Script:

local remoteEvent = game.ReplicatedStorage.RemoteEvent
game:GetService("RunService").RenderStepped:Connect(function()
   remoteEvent:FireServer(workspace.currentcamera.cframe)
end)

Global Script(put in server script service,this part is adapted from GuestCapone’s thing i found from the toolbox, converted to server script):

--THIS MIGHT NOT BE THE BEST SOLUTION (but it works :D)

game.Players.PlayerAdded:Connect(function(plr)			
	plr.CharacterAdded:Connect(function(char)		
		local i = 0
		local NeckC0
		local NeckC1
		game.ReplicatedStorage.Events.tiltChar.OnServerEvent:Connect(function(plr,cf)
			local char = plr.Character
			--cf is the camera's cframe
			
			local torso = char:WaitForChild("Torso")
			local Neck = torso:WaitForChild("Neck")
			local LeftShoulder = torso:WaitForChild("Left Shoulder")
			local RightShoulder = torso:WaitForChild("Right Shoulder")
			local Weapon = torso:WaitForChild("ToolGrip")
			local Humanoid = char:WaitForChild("Humanoid")
			
			local riseMagnitude = 0.9
			local RC1 = CFrame.new(1, .5, 0, 0, 0, riseMagnitude, 0, riseMagnitude, 0, -riseMagnitude, 0, 0)
			local LC1 = CFrame.new(-1, .5, 0, 0, 0, -riseMagnitude, 0, riseMagnitude, 0, riseMagnitude, 0, 0)
			
			if i == 0 then -- delete this and head will spin crazy
				NeckC0 = Neck.C0
				NeckC1 = Neck.C1
				i = 1
			end
			
			local offset = CFrame.Angles(0,0,cf.lookVector.Y)
			local tool = char:FindFirstChildOfClass("Tool")
			
			if tool then --arm follow camera when tool equipped
				RightShoulder.C0 = RC1 * offset
				LeftShoulder.C0 = LC1 * offset:inverse()
				Weapon.C0 = CFrame.Angles(cf.lookVector.y,0,0)
			else
				RightShoulder.C0 = RC1 * CFrame.Angles(0,0,0)
				LeftShoulder.C0 = LC1 * CFrame.Angles(0,0,0)
			end
			Neck.C0 = NeckC0 * CFrame.Angles(cf.lookVector.y, 0, 0):inverse()
		end)
	end)
end)
8 Likes