tyridge77

MoveStuff

Jul 30th, 2015
322
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.84 KB | None | 0 0
  1. wait();
  2. rst = game:GetService("RunService").RenderStepped;
  3.  
  4.  
  5. local asin = math.asin;
  6. local atan2 = math.atan2;
  7. local rad = math.rad;
  8. local abs = math.abs;
  9. local deg = math.deg
  10.  
  11.  
  12. local player = game.Players.LocalPlayer;
  13. local Mouse = player:GetMouse();
  14. local Camera = Workspace.CurrentCamera;
  15. local char = player.Character;
  16. local human = char.Humanoid;
  17. --animate = char:WaitForChild("Animate");
  18. --animate.Disabled = true;
  19. --wait(1);
  20. --animate:Destroy();
  21. wait(1);
  22.  
  23. local torso = char.Torso;
  24.  
  25. local model = char;
  26.  
  27. local human = char.Humanoid;
  28.  
  29. local Neck = torso.Neck;
  30. local head = char.Head;
  31. local ls = torso["Left Shoulder"];
  32. local rs = torso["Right Shoulder"];
  33. local lh = torso["Left Hip"];
  34. local rh = torso["Right Hip"];
  35.  
  36.  
  37.  
  38. local hrp = char["HumanoidRootPart"]["RootJoint"];
  39. local la = char["Left Arm"];
  40. local ra = char["Right Arm"];
  41.  
  42.  
  43.  
  44.  
  45. hrp.C0 = CFrame.new(0, 0, 0, 1, 1.68453017e-022, -4.14363114e-024, -1.68453017e-022, 1, 1.72377808e-022, 4.14363114e-024, -1.72377808e-022, 1)
  46.  
  47. hrp.C1 = CFrame.new(0, 0, 0, 1, 1.68453017e-022, -4.14363114e-024, -1.68453017e-022, 1, 1.72377808e-022, 4.14363114e-024, -1.72377808e-022, 1)
  48.  
  49. ls.C0 = CFrame.new(-1, 0.5, 0, -4.37113883e-008, 0, -1, 0, 0.99999994, 0, 1, 0, -4.37113883e-008);
  50.  
  51. ls.C1 = CFrame.new(0.5, 0.5, 0, -4.37113883e-008, 0, -1, 0, 0.99999994, 0, 1, 0, -4.37113883e-008);
  52.  
  53.  
  54. rs.C0 = CFrame.new(1, 0.5, 0, -4.37113883e-008, 0, 1, -0, 0.99999994, 0, -1, 0, -4.37113883e-008);
  55.  
  56. rs.C1 = CFrame.new(-0.5, 0.5, 0, -4.37113883e-008, 0, 1, 0, 0.99999994, 0, -1, 0, -4.37113883e-008);
  57.  
  58.  
  59. lh.C0 = CFrame.new(-1, -1, 0, -4.37113883e-008, 0, -1, 0, 0.99999994, 0, 1, 0, -4.37113883e-008);
  60.  
  61. lh.C1 = CFrame.new(-0.5, 1, 0, -4.37113883e-008, 0, -1, 0, 0.99999994, 0, 1, 0, -4.37113883e-008);
  62.  
  63.  
  64. rh.C0 = CFrame.new(1, -1, 0, -4.37113883e-008, 0, 1, -0, 0.99999994, 0, -1, 0, -4.37113883e-008);
  65.  
  66.  
  67. rh.C1 = CFrame.new(0.5, 1, 0, -4.37113883e-008, 0, 1, 0, 0.99999994, 0, -1, 0, -4.37113883e-008);
  68.  
  69.  
  70. Neck.C0 = CFrame.new(0, 1, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0);
  71.  
  72. Neck.C1 = CFrame.new(0, -0.5, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
  73.  
  74.  
  75. rhc0 = rh.C0;
  76. lhc0 = lh.C0;
  77.  
  78. local lsc0 = ls.C0;
  79. local rsc0 = rs.C0;
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87. local MovingNeck = false;
  88. local ForceLeft = false;
  89. local ForceRight = false;
  90. local LockedArms = false;
  91. local ForceLightning = false;
  92.  
  93.  
  94.  
  95. local WalkSpeed = 10;
  96. local fre = 8;
  97.  
  98.  
  99. local hrpc0 = hrp.C0;
  100.  
  101. local rootpart = hrp.Parent;
  102. LockedArms = false;
  103. MovingNeck = false;
  104. CtrlDown = 0;
  105.  
  106. function clamp(v,mi,ma)
  107. if v<mi then return mi elseif v>ma then return ma else return v end
  108. end
  109.  
  110.  
  111. locked = false;
  112.  
  113. function rec(p,b)
  114. for _,v in pairs(p:GetChildren()) do
  115. if v:isA("BasePart") then
  116. v.CanCollide = b;
  117. else
  118. rec(v,b);
  119. end
  120. end
  121. end
  122. Collide = true;
  123. situps = false;
  124. Mouse.KeyDown:connect(function(k)
  125. if k == "y" then
  126. CtrlDown = CtrlDown == 0 and 1 or 0;
  127. end
  128. if k == "k" then
  129. situps = not situps;
  130. if situps then
  131. rootpart.Anchored = true;
  132. local orig = rootpart.CFrame;
  133. local cf = CFrame.new(orig.X,1,orig.Z);
  134. rootpart.CFrame = CFrame.new(cf.p,cf.p+Vector3.new(0,10,0));
  135. else
  136. local orig = rootpart.CFrame;
  137. local cf = CFrame.new(orig.X,5,orig.Z);
  138. rootpart.CFrame = cf;
  139. rootpart.Anchored = false;
  140. end
  141. end
  142.  
  143. if k == "x" then
  144. Collide = not Collide;
  145. rec(char,Collide);
  146. print("CanCollide: ",Collide);
  147. end
  148. if k == "t" then
  149. locked = not locked;
  150. if not locked then
  151. lockedhrp = nil;
  152. lockedrh = nil;
  153. lockedlh = nil;
  154. else
  155. lockedhrp = hrp.C0;
  156. lockedlh = lh.C0;
  157. lockedrh = rh.C0;
  158. end
  159. end
  160. if k == "q" then
  161. ForceLeft = true;
  162. end
  163. if k == "e" then
  164. ForceRight = true;
  165. end
  166. if k == "v" then
  167. LockedArms = not LockedArms; print("Locked arms: ",LockedArms);
  168. end
  169. if k == "r" then
  170. MovingNeck = not MovingNeck;
  171. end
  172.  
  173. if k == "\48" and (not ForceRight and not ForceLeft) then
  174. WalkSpeed = 18;
  175. fre = 12;
  176. end
  177. end)
  178.  
  179.  
  180. Mouse.KeyUp:connect(function(k)
  181. if k == "\48" then
  182. WalkSpeed = 10;
  183. fre = 8;
  184. end
  185. if k == "q" then
  186. ForceLeft = false;
  187. end
  188. if k == "e" then
  189. ForceRight = false;
  190. end
  191. end)
  192.  
  193.  
  194.  
  195. while true do
  196.  
  197.  
  198. time = Workspace.DistributedGameTime;
  199.  
  200. if torso.Velocity.magnitude > 1 and not lockls and not lockrs then
  201.  
  202. local sin = math.sin(time*fre);
  203. local desangle = 1.1 * sin;
  204. lh.MaxVelocity = 1;
  205. rh.DesiredAngle = desangle
  206. rs.DesiredAngle = RightStationary and desangle or 0;
  207. lh.DesiredAngle = desangle;
  208. ls.DesiredAngle = LeftStationary and desangle or 0;
  209. else
  210. rh.DesiredAngle = 0;
  211. rs.DesiredAngle = 0;
  212. lh.DesiredAngle = 0;
  213. ls.DesiredAngle = 0;
  214. end
  215.  
  216.  
  217.  
  218. local MouseY = Mouse.Y;
  219. local MouseX = Mouse.X;
  220. local d = torso.CFrame:pointToObjectSpace(Mouse.UnitRay.Origin+Mouse.UnitRay.Direction.unit*1000);
  221. mouseX = atan2(d.X,-d.Z)*2
  222. mouseY = asin(-d.unit.Y)*2
  223.  
  224. mouseYn = asin(((MouseY/Mouse.ViewSizeY)-0.5)*2);
  225. if (not (Mouse.Y <= 3 or Mouse.X >= Mouse.ViewSizeX - 5 or Mouse.X <= 3 or Mouse.Y >= Mouse.ViewSizeY - 5)) then
  226.  
  227. local CamY = clamp(Camera.CoordinateFrame.lookVector.Y,-1,0)*2;
  228.  
  229.  
  230. AngleY = clamp(-mouseY,-2.3,3.05); --1.3,2.05
  231. AngleYn = clamp(-mouseYn,-2.3,3.05);
  232. AngleX = clamp(-mouseX,-1.5,1.5);
  233.  
  234. AngleYArm = AngleY-CamY;
  235. local ArmX = clamp(AngleX,-1.5,0.75);
  236. local ArmY = AngleYArm+(1.25+AngleYArm)
  237.  
  238. local TorsoY = clamp(AngleYn*2,-2,2);
  239.  
  240.  
  241. local HeadY = clamp((AngleY-CamY)*2,-0.75,0.8);
  242.  
  243. if CtrlDown >0 then
  244. hrp.C0 = lockedhrp or
  245. CFrame.new(0,-(math.abs(TorsoY)/2)*1.25,-(math.abs(TorsoY)/2)*.5)*CFrame.Angles((CtrlDown)*TorsoY,0,0)
  246. lh.C0 = lockedlh or lhc0*CFrame.Angles(0,0,CtrlDown*TorsoY)
  247.  
  248. rh.C0 = lockedrh or rhc0*CFrame.Angles(0,0,CtrlDown*-TorsoY)
  249. else
  250. hrp.C0 = lockedhrp or hrpc0; lh.C0 = lhc0; rh.C0 = rhc0;
  251. end
  252.  
  253.  
  254. if MovingNeck then
  255. Neck.C0=CFrame.new(0,1,0)*CFrame.Angles(HeadY,AngleX,0)*CFrame.new(0,0.5,0)
  256. Neck.C1 = CFrame.new();
  257. end
  258.  
  259.  
  260. if ForceLeft then
  261. LeftStationary = false;
  262. ls.C0 = lsc0*CFrame.Angles(-rad(15),ArmX,-ArmY);
  263. elseif not LeftStationary then
  264. LeftStationary = true;
  265. ls.C0=lsc0;
  266. end
  267. if ForceRight then
  268. RightStationary = false;
  269. rs.C0 = rsc0*CFrame.Angles(-rad(15),ArmX,ArmY);
  270. elseif not RightStationary then
  271. RightStationary = true;
  272. rs.C0=rsc0;
  273. end
  274. end
  275.  
  276.  
  277.  
  278.  
  279. rst:wait();
  280. end
Advertisement
Add Comment
Please, Sign In to add comment