-- setup based on rig type (r15 or r6)
if humanoid.RigType == Enum.HumanoidRigType.R15 then
	rigtype = "R15"
	torso = character:WaitForChild("UpperTorso")
	lowertorso = character:WaitForChild("LowerTorso")
	larm = character:WaitForChild("LeftUpperArm")
	rarm = character:WaitForChild("RightUpperArm")
	-- setup variables
	waist = torso:WaitForChild("Waist")
	oldc0 = waist.C0
	leftshoulder = character:WaitForChild("LeftUpperArm"):WaitForChild("LeftShoulder")
	rightshoulder = character:WaitForChild("RightUpperArm"):WaitForChild("RightShoulder")
	-- make fake lower torso
	fakelowertorso = Instance.new("Part")
	fakelowertorso.Name = "LowerTorso"
	fakelowertorso.CanCollide = false
	fakelowertorso.Anchored = false
	fakelowertorso.CanTouch = false
	fakelowertorso.Transparency = 1
	--fakelowertorso.Massless = true
	fakelowertorso.Parent = viewmodel
	--
	faketorso.Size = torso.Size
	fakeroot.Size = rootpart.Size
	fakelowertorso.Size = lowertorso.Size
	faketorso.CFrame = fakeroot.CFrame
	roothipclone = lowertorso:WaitForChild("Root"):Clone()
	roothipclone.Parent = fakelowertorso
	roothipclone.Part0 = fakeroot
	roothipclone.Part1 = fakelowertorso
	--
	if firstperson_waist_movements_enabled then
		waistclone = torso:WaitForChild("Waist"):Clone()
		waistclone.Parent = faketorso
		waistclone.Part0 = fakelowertorso
		waistclone.Part1 = faketorso
	else
		-- waist movements not enabled, replace waist joint with a weld
		waistclone = Instance.new("Weld")
		waistclone.Parent = faketorso
		waistclone.Part0 = fakelowertorso
		waistclone.Part1 = faketorso
		waistclone.C0 = waist.C0
		waistclone.C1 = waist.C1
	end
	--
	leftshoulderclone = leftshoulder:Clone()
	leftshoulderclone.Name = "LeftShoulderClone"
	leftshoulderclone.Parent = faketorso
	leftshoulderclone.Part0 = larm
	--
	rightshoulderclone = rightshoulder:Clone()
	rightshoulderclone.Name = "RightShoulderClone"
	rightshoulderclone.Parent = faketorso
	rightshoulderclone.Part0 = rarm
	-- add the arms
	table.insert(armparts, character:WaitForChild("RightLowerArm"))
	table.insert(armparts, character:WaitForChild("LeftUpperArm"))
	table.insert(armparts, character:WaitForChild("RightUpperArm"))
	table.insert(armparts, character:WaitForChild("LeftLowerArm"))
	table.insert(armparts, character:WaitForChild("RightLowerArm"))
	table.insert(armparts,character:WaitForChild("LeftHand"))
	table.insert(armparts,character:WaitForChild("RightHand"))
else
	rigtype = "R6"
	torso = character:WaitForChild("Torso")
	-- add the arms
	table.insert(armparts, character:WaitForChild("Right Arm"))
	table.insert(armparts, character:WaitForChild("Left Arm"))
	-- setup variables
	roothip = rootpart:FindFirstChildOfClass("Motor6D")
	oldc0 = roothip.C0
	leftshoulder = torso:WaitForChild("Left Shoulder")
	rightshoulder = torso:WaitForChild("Right Shoulder")
	--
	faketorso.Size = torso.Size
	fakeroot.Size = rootpart.Size
	faketorso.CFrame = fakeroot.CFrame
	roothipclone = roothip:Clone()
	roothipclone.Parent = fakeroot
	roothipclone.Part0 = fakeroot
	roothipclone.Part1 = faketorso
	--
	leftshoulderclone = leftshoulder:Clone()
	leftshoulderclone.Name = "LeftShoulderClone"
	leftshoulderclone.Parent = torso
	leftshoulderclone.Part0 = torso
	--
	rightshoulderclone = rightshoulder:Clone()
	rightshoulderclone.Name = "RightShoulderClone"
	rightshoulderclone.Parent = torso
	rightshoulderclone.Part0 = torso
	--
	larm = character:WaitForChild("Left Arm")
	rarm = character:WaitForChild("Right Arm")
end

if firstperson_arm_transparency >= 1 then
	armsvisible = false
end