Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- script.Parent = game.StarterGui
- local RunSrv = game:GetService("RunService");
- local Wrks = game:GetService("Workspace");
- local Plrs = game:GetService("Players");
- local Ang = CFrame.Angles;
- local aSin = math.asin;
- local aTan = math.atan;
- local Cam = Wrks.CurrentCamera;
- local Plr = Plrs.LocalPlayer;
- local Mouse = Plr:GetMouse();
- local Body = Wrks:WaitForChild(Plr.Name);
- local Head = Body:WaitForChild("Head");
- local Hum = Body:WaitForChild("Humanoid");
- local Core = Body:WaitForChild("HumanoidRootPart");
- local IsR6 = (Hum.RigType.Value==0);
- local Trso = (IsR6 and Body:WaitForChild("Torso")) or Body:WaitForChild("UpperTorso");
- local Neck = (IsR6 and Trso:WaitForChild("Neck")) or Head:WaitForChild("Neck");
- local MseGuide = true;
- local Fctor = 1;
- local OrgnC0 = Neck.C0;
- Neck.MaxVelocity = 1/3
- coroutine.resume(coroutine.create(function()
- while RunSrv.RenderStepped:wait() and Hum:GetState().Value~=15 do
- local CamCF = Cam.CoordinateFrame
- if ((IsR6 and Body["Torso"]) or Body["UpperTorso"])~=nil and Body["Head"]~=nil then
- local TrsoLV = Trso.CFrame.lookVector
- local HdPos = Head.CFrame.p
- if ((IsR6 and Trso["Neck"]) or Head["Neck"])~=nil then
- if Cam.CameraSubject:IsDescendantOf(Body) or Cam.CameraSubject:IsDescendantOf(Plr) then
- local Dist = nil;
- local Diff = nil;
- if not MseGuide then
- Dist = (Head.CFrame.p-CamCF.p).magnitude
- Diff = Head.CFrame.Y-CamCF.Y
- if not IsR6 then
- Neck.C0 = OrgnC0*Ang((aSin(Diff/Dist)*Fctor), -(((HdPos-CamCF.p).Unit):Cross(TrsoLV)).Y, 0)
- else --[ R15s actually have the properly oriented Neck CFrame. ]
- Neck.C0 = OrgnC0*Ang(-(aSin(Diff/Dist)*Fctor), 0, -(((HdPos-CamCF.p).Unit):Cross(TrsoLV)).Y)
- end
- else
- local _, Point = Wrks:FindPartOnRay(Ray.new(Head.CFrame.p, Mouse.Hit.lookVector), Wrks, false, true)
- Dist = (Head.CFrame.p-Point).magnitude
- Diff = Head.CFrame.Y-Point.Y
- if not IsR6 then
- Neck.C0 = OrgnC0*Ang(-(aTan(Diff/Dist)*Fctor), (((HdPos-Point).Unit):Cross(TrsoLV)).Y*Fctor, 0)
- else
- Neck.C0 = OrgnC0*Ang((aTan(Diff/Dist)*Fctor), 0, (((HdPos-Point).Unit):Cross(TrsoLV)).Y*Fctor)
- end
- end
- end
- end
- end
- end
- end))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement