Feedback on tilt script

local char = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()

--joints
local lShoulder = char.LeftUpperArm.LeftShoulder
local rShoulder = char.RightUpperArm.RightShoulder
local neck = char.Head.Neck
local waist = char.UpperTorso.Waist

--Setup clone body
local CopyModel = Instance.new("Model")
char.LeftUpperArm:Clone().Parent = CopyModel
char.LeftLowerArm:Clone().Parent = CopyModel
char.LeftHand:Clone().Parent = CopyModel
char.UpperTorso:Clone().Parent = CopyModel
char.RightUpperArm:Clone().Parent = CopyModel
char.RightLowerArm:Clone().Parent = CopyModel
char.RightHand:Clone().Parent = CopyModel
char.Head:Clone().Parent = CopyModel

CopyModel.LeftLowerArm.LeftElbow.Part0 = CopyModel.LeftUpperArm
CopyModel.LeftHand.LeftWrist.Part0 = CopyModel.LeftLowerArm
CopyModel.LeftUpperArm.LeftShoulder.Part0 = CopyModel.UpperTorso
CopyModel.UpperTorso.Waist.Part0 = char.LowerTorso
CopyModel.RightLowerArm.RightElbow.Part0 = CopyModel.RightUpperArm
CopyModel.RightHand.RightWrist.Part0 = CopyModel.RightLowerArm
CopyModel.RightUpperArm.RightShoulder.Part0 = CopyModel.UpperTorso
CopyModel.Head.Neck.Part0 = CopyModel.UpperTorso

--Save offset data
local DiffC0 = {}
local DiffC1 = {}

    --LeftUpperArm
DiffC0[1] = char.LeftUpperArm.LeftShoulder.C0.Position
DiffC1[1] = char.LeftUpperArm.LeftShoulder.C1.Position

	--LeftLowerArm
DiffC0[2] = char.LeftLowerArm.LeftElbow.C0.Position
DiffC1[2] = char.LeftLowerArm.LeftElbow.C1.Position

	--LeftHand
DiffC0[3] = char.LeftHand.LeftWrist.C0.Position
DiffC1[3] = char.LeftHand.LeftWrist.C1.Position

    --UpperTorso
DiffC0[4] = char.UpperTorso.Waist.C0.Position
DiffC1[4] = char.UpperTorso.Waist.C1.Position

	--RightUpperArm
DiffC0[5] = char.RightUpperArm.RightShoulder.C0.Position
DiffC1[5] = char.RightUpperArm.RightShoulder.C1.Position

	--RightLowerArm
DiffC0[6] = char.RightLowerArm.RightElbow.C0.Position
DiffC1[6] = char.RightLowerArm.RightElbow.C1.Position

	--RightHand
DiffC0[7] = char.RightHand.RightWrist.C0.Position
DiffC1[7] = char.RightHand.RightWrist.C1.Position

	--Head
DiffC0[8] = char.Head.Neck.C0.Position
DiffC1[8] = char.Head.Neck.C1.Position





--duplicate clothing/Accessories
for _,v in pairs(char:GetChildren()) do
	if v:IsA("Accessory") or v:IsA("Clothing") or v:IsA("ShirtGraphic") or v:IsA("BodyColors") then
		v:Clone().Parent = CopyModel
	end
end

--add humanoid
local cloneHum = char.Humanoid:Clone()
cloneHum.PlatformStand = true
cloneHum.Parent = CopyModel
cloneHum.NameDisplayDistance = 0
cloneHum.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None




--place cloned arms in workspace
CopyModel.Parent = game.Workspace


--make invisible/weld accessories
for _, i in pairs(CopyModel:GetChildren()) do
	if char:FindFirstChild(i.Name) and i:IsA("BasePart") then
		char[i.Name].Transparency = 1
	end
	
	if char:FindFirstChild(i.Name) and i:IsA("Accessory") then
		local handle = char[i.Name]:FindFirstChild("Handle")
		if handle then handle.Transparency = 1 else continue end
		
		local weldName = char[i.Name].Handle.AccessoryWeld.Part1.Name
		i.Handle.AccessoryWeld.Part1 = CopyModel:FindFirstChild(weldName)
	end
end
char.Head.Transparency = 0.99


game:GetService("RunService").RenderStepped:Connect(function()
	--if not char:FindFirstChildOfClass("Tool") then return end
	
	local mouse = game.Players.LocalPlayer:GetMouse()
	local pos = mouse.Hit
	
	
	
	
	
	
	local lookCF = CFrame.new(char.PrimaryPart.Position, pos.Position)
	local x, y, z = lookCF:ToOrientation()
	
	local targetCF = CFrame.new(char.PrimaryPart.Position) * CFrame.fromOrientation(0, y, 0)
	
	
	char:PivotTo(   char.PrimaryPart.CFrame:Lerp(targetCF, .5)  )
	
	
	neck.C0 = neck.C0:Lerp( CFrame.new(neck.C0.Position) * CFrame.fromOrientation(x * .5, 0, 0) , .5 )
	--CopyModel.UpperTorso.Waist.C0 = CopyModel.UpperTorso.Waist.C0:Lerp( CFrame.new(CopyModel.UpperTorso.Waist.C0.Position) * CFrame.fromOrientation(x * .5, 0, 0) , .5 )
	
	
	
	
	--Left Upper Arm
	local diffOrientation = char.UpperTorso.CFrame:Inverse() * char.LeftUpperArm.CFrame 
	diffOrientation = diffOrientation - diffOrientation.Position
	
	CopyModel.LeftUpperArm.LeftShoulder.C0 = diffOrientation + DiffC0[1]
	CopyModel.LeftUpperArm.LeftShoulder.C1 = CFrame.fromOrientation(-x * .5, 0, 0) + DiffC1[1]
	
	--Left Lower Arm
	local diffOrientation = char.LeftUpperArm.CFrame:Inverse() * char.LeftLowerArm.CFrame 
	diffOrientation = diffOrientation - diffOrientation.Position

	CopyModel.LeftLowerArm.LeftElbow.C0 = diffOrientation + DiffC0[2]
	CopyModel.LeftLowerArm.LeftElbow.C1 = CFrame.new() + DiffC1[2]
	
	--Left Hand
	local diffOrientation = char.LeftLowerArm.CFrame:Inverse() * char.LeftHand.CFrame 
	diffOrientation = diffOrientation - diffOrientation.Position

	CopyModel.LeftHand.LeftWrist.C0 = diffOrientation + DiffC0[3]
	CopyModel.LeftHand.LeftWrist.C1 = CFrame.new() + DiffC1[3]
	
	
	
	--Upper Torso
	diffOrientation = char.LowerTorso.CFrame:Inverse() * char.UpperTorso.CFrame
	diffOrientation = diffOrientation - diffOrientation.Position
	
	CopyModel.UpperTorso.Waist.C0 = diffOrientation + DiffC0[4]
	CopyModel.UpperTorso.Waist.C1 = CFrame.fromOrientation(-x * .5, 0, 0) + DiffC1[4]
	
	
	
	--Right Upper Arm
	local diffOrientation = char.UpperTorso.CFrame:Inverse() * char.RightUpperArm.CFrame 
	diffOrientation = diffOrientation - diffOrientation.Position

	CopyModel.RightUpperArm.RightShoulder.C0 = diffOrientation + DiffC0[5]
	CopyModel.RightUpperArm.RightShoulder.C1 = CFrame.fromOrientation(-x * .5, 0, 0) + DiffC1[5]

	--Right Lower Arm
	local diffOrientation = char.RightUpperArm.CFrame:Inverse() * char.RightLowerArm.CFrame 
	diffOrientation = diffOrientation - diffOrientation.Position

	CopyModel.RightLowerArm.RightElbow.C0 = diffOrientation + DiffC0[6]
	CopyModel.RightLowerArm.RightElbow.C1 = CFrame.new() + DiffC1[6]

	--Right Hand
	local diffOrientation = char.RightLowerArm.CFrame:Inverse() * char.RightHand.CFrame 
	diffOrientation = diffOrientation - diffOrientation.Position

	CopyModel.RightHand.RightWrist.C0 = diffOrientation + DiffC0[7]
	CopyModel.RightHand.RightWrist.C1 = CFrame.new() + DiffC1[7]
	
	
	--Head
	diffOrientation = char.UpperTorso.CFrame:Inverse() * char.Head.CFrame
	diffOrientation = diffOrientation - diffOrientation.Position

	CopyModel.Head.Neck.C0 = diffOrientation + DiffC0[8]
	CopyModel.Head.Neck.C1 = CFrame.fromOrientation(-x * .5, 0, 0) + DiffC1[8]
	
end)

This script is designed to tilt the character’s arms, torso and head toward the player’s mouse position. I created it with the intention of enabling it while projectile weapons are equipped, and returning the character to normal behavior otherwise (though I havent implemented it for this purpose yet)

It works by making everything from the waist up invisible, then copying those rig pieces onto a clone model. That model is then joined to the player model at the lower torso, and any animations played on the character will be mirrored onto the model. this allows for the rotation of joints without interference from roblox core scripts.

Pros:

  • rotates flawlessly

Cons:

  • probably not very resource friendly
  • Any attempt to weld an item to the character (i.e. accessories, armor) will need to be mirrored onto the tilting clone, and made transparent on the player model. This will also have to be undone upon disabling this feature (i.e unequipping the weapon), so all transparency data for all added accessories and armor will need to be saved and reapplied upon disabling.