Hello, I have read countless of tutorials trying to figure out this crap, for some reason or lack of understanding from my side every time the player arms look weird (like a tired drunk guy) I have tried fixing it but I do not have the understand on how to do it if you can please help me out this would me a lot for me:
Video Demonstrating:
Here the code:
player.CharacterAdded:Connect(function(character)
local TorsoC0 = character:WaitForChild("UpperTorso"):WaitForChild("Waist").C0
local HeadC0 = character:WaitForChild("Head"):WaitForChild("Neck")
local rShoulder = player.Character.RightUpperArm.RightShoulder;
local lShoulder = player.Character.LeftUpperArm.LeftShoulder;
local tiltPart = Instance.new("Part");
tiltPart.Size = Vector3.new(.1, .1, .1);
tiltPart.Transparency = 1;
tiltPart.CanCollide = false;
tiltPart.Name = "tiltPart";
tiltPart.Parent = player.Character;
local tJoint = Instance.new("Motor6D");
tJoint.Name = "tiltJoint"
tJoint.MaxVelocity = math.pi*2*0.01;
tJoint.Part0 = player.Character.Head;
tJoint.Part1 = tiltPart;
tJoint.Parent = player.Character.Head;
local humanoid = character:WaitForChild("Humanoid")
local rootPart = character:WaitForChild("HumanoidRootPart")
local cameraAngleX = 0
local cameraAngleY = 0
humanoid.AutoRotate = false
local function playerInput(actionName, inputState, inputObject)
if inputState == Enum.UserInputState.Change then
cameraAngleX -= inputObject.Delta.X
cameraAngleY = math.clamp(cameraAngleY - inputObject.Delta.Y * 0.4, -75, 75)
end
end
ContextActionService:BindAction("PlayerInput", playerInput, false, Enum.UserInputType.MouseMovement, Enum.UserInputType.Touch)
RunService:BindToRenderStep("CameraUpdate", Enum.RenderPriority.Camera.Value, function()
local cameralookvectorY = workspace.CurrentCamera.CFrame.lookVector.Y
local radian = math.asin(cameralookvectorY)
local theta = tJoint.CurrentAngle
game.Players.LocalPlayer.Character.UpperTorso.Waist.C0 = TorsoC0*CFrame.fromEulerAnglesYXZ(radian,0,0)
HeadC0.C0 = CFrame.new(HeadC0.C0.Position) * CFrame.Angles(camera.CFrame.LookVector.Y, 0, 0)
rShoulder.C0 = rShoulder.C0 * CFrame.fromEulerAnglesYXZ(theta*0.5, 0, 0);
lShoulder.C0 = lShoulder.C0 * CFrame.fromEulerAnglesYXZ(theta*0.5, 0, 0);
local startCFrame = CFrame.new(rootPart.CFrame.Position) * CFrame.Angles(0, math.rad(cameraAngleX), 0) * CFrame.Angles(math.rad(cameraAngleY), 0, 0)
local cameraCFrame = startCFrame:PointToWorldSpace(cameraOffset)
local cameraFocus = startCFrame:PointToWorldSpace(Vector3.new(cameraOffset.X, cameraOffset.Y, -100000))
camera.CFrame = CFrame.lookAt(cameraCFrame, cameraFocus)
local lookingCFrame = CFrame.lookAt(rootPart.Position, camera.CFrame:PointToWorldSpace(Vector3.new(0, 0, -100000)))
rootPart.CFrame = CFrame.fromMatrix(rootPart.Position, lookingCFrame.XVector, rootPart.CFrame.YVector)
end)
end)
local function focusControl(actionName, inputState, inputObject)
if inputState == Enum.UserInputState.Begin then
camera.CameraType = Enum.CameraType.Scriptable
UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
UserInputService.MouseIconEnabled = true --Optional
ContextActionService:UnbindAction("FocusControl")
end
end
ContextActionService:BindAction("FocusControl", focusControl, false, Enum.UserInputType.MouseButton1, Enum.UserInputType.Touch, Enum.UserInputType.Focus)
For context this script makes it so the player has third person view (like in fortnite) and tries to make the character rotate with the mouse but It only work pretty well for torso and head