Because of the risk of R6 getting depreciated, and the R15 to R6 adapter not working as well, I am trying to allow both R6 and R15 to work for my game. One of the things I have to change around a bit is limb rotation with the camera.
How it works is that the head will always rotate while the arms will only rotate if there is a tool detected. The head has no issues, just the arms.
This is what it looks like functioning in R6:
It only works when the character spawns with no animations at all:
The rest of the time it looks like this:
There are no other scripts that I know of that attempt to change the C0 of the Motor6s in the arms. I should also note that if I do move fast enough, it appears that it attempts to apply the rotation, but then snaps back to the state in the 3rd image.
Here is the code for the rotation:
local Resources = {
Character = script.Parent,
Head = script.Parent:WaitForChild("Head"),
LeftArmMotor = script.Parent:WaitForChild("LeftUpperArm"):WaitForChild("LeftShoulder"),
RightArmMotor = script.Parent:WaitForChild("RightUpperArm"):WaitForChild("RightShoulder"),
HeadMotor = script.Parent.Head:WaitForChild("Neck"),
Root = script.Parent:WaitForChild("HumanoidRootPart"),
Communicator = ReplicatedStorage:WaitForChild("RemoteEvent"), --Censored for security
Camera = game.Workspace:WaitForChild("Camera")
}
--Variables
local HasTool = false
local SendOut = 0
--Functions
local Functions = {
OffsetMotors = function()
if Resources.Root ~= nil and Resources.Character.Humanoid.Health > 0 then
if Resources.Character.Humanoid.RigType == Enum.HumanoidRigType.R6 then
Resources.HeadMotor.C0 = CFrame.new(Resources.HeadMotor.C0.Position) * CFrame.Angles(Resources.Camera.CFrame.LookVector.Y + math.rad(90), math.rad(-180), -Resources.Root.CFrame:ToObjectSpace(Resources.Camera.CFrame).LookVector.X)
else
Resources.HeadMotor.C0 = CFrame.new(Resources.HeadMotor.C0.Position) * CFrame.Angles(Resources.Camera.CFrame.LookVector.Y, -Resources.Root.CFrame:ToObjectSpace(Resources.Camera.CFrame).LookVector.X, 0)
end
if HasTool == true then
if Resources.Character.Humanoid.RigType == Enum.HumanoidRigType.R6 then
Resources.LeftArmMotor.C0 = CFrame.new(Vector3.new(-1, 0.5, 0)) * CFrame.Angles(Resources.Camera.CFrame.LookVector.Y * 1.5, math.rad(-90), 0)
Resources.RightArmMotor.C0 = CFrame.new(Vector3.new(1, 0.5, 0)) * CFrame.Angles(Resources.Camera.CFrame.LookVector.Y * 1.5, math.rad(90), 0)
else
Resources.LeftArmMotor.C0 = CFrame.new(Resources.LeftArmMotor.C0.Position) * CFrame.Angles(Resources.Camera.CFrame.LookVector.Y * 1.5, 0, 0)
Resources.RightArmMotor.C0 = CFrame.new(Resources.RightArmMotor.C0.Position) * CFrame.Angles(Resources.Camera.CFrame.LookVector.Y * 1.5, 0, 0)
end
else
if Resources.Character.Humanoid.RigType == Enum.HumanoidRigType.R6 then
Resources.LeftArmMotor.C0 = CFrame.new(Resources.LeftArmMotor.C0.Position) * CFrame.Angles(0, math.rad(-90), 0)
Resources.RightArmMotor.C0 = CFrame.new(Resources.RightArmMotor.C0.Position) * CFrame.Angles(0, math.rad(90), 0)
else
Resources.LeftArmMotor.C0 = CFrame.new(Resources.LeftArmMotor.C0.Position) * CFrame.Angles(0, 0, 0)
Resources.RightArmMotor.C0 = CFrame.new(Resources.RightArmMotor.C0.Position) * CFrame.Angles(0, 0, 0)
end
end
if SendOut >= 4 then
Resources.Communicator:FireServer(Resources.HeadMotor.C0, Resources.LeftArmMotor.C0, Resources.RightArmMotor.C0, Resources.Camera.CFrame.LookVector.Y)
SendOut = 0
else
SendOut += 1
end
end
end,
ChildrenChanged = function()
if Resources.Character:FindFirstChildOfClass("Tool") then
HasTool = true
else
HasTool = false
end
end,
}
--Events
RunService.RenderStepped:Connect(Functions.OffsetMotors)
Resources.Character.ChildAdded:Connect(Functions.ChildrenChanged)
Resources.Character.ChildRemoved:Connect(Functions.ChildrenChanged)
--Code
Here is the server-end code
ReplicateToServer = function(player, head, leftArm, rightArm, lookVector)
if player.Character ~= nil and player.Character.Humanoid ~= nil and player.Character.Humanoid.Health > 0 then
if player.Character.Humanoid.RigType == Enum.HumanoidRigType.R6 and player.Character.Torso ~= nil then
player.Character.Torso["Neck"].C0 = head
player.Character.Torso["Left Shoulder"].C0 = leftArm
player.Character.Torso["Right Shoulder"].C0 = rightArm
elseif player.Character.Humanoid.RigType == Enum.HumanoidRigType.R15 and player.Character.RightUpperArm ~= nil and player.Character.LeftUpperArm ~= nil and player.Character.Head ~= nil then
player.Character.Head["Neck"].C0 = head
player.Character.LeftUpperArm["LeftShoulder"].C0 = CFrame.new(player.Character.LeftUpperArm.LeftShoulder.C0.Position) * CFrame.Angles(lookVector, 0, 0)
player.Character.RightUpperArm["RightShoulder"].C0 = CFrame.new(player.Character.RightUpperArm.RightShoulder.C0.Position) * CFrame.Angles(lookVector, 0, 0)
end
end
end,
Any help would be appreciated. Thanks!