Advertisement
Wweroblox12121212

Untitled

Jul 26th, 2017
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.50 KB | None | 0 0
  1. local npc = Instance.new("Model")
  2. npc.Name = "TestDummy"
  3. local leftarm = Instance.new("Part", npc)
  4. leftarm.Size = Vector3.new(1, 2, 1)
  5. leftarm.formFactor = "Symmetric"
  6. local leftleg = Instance.new("Part", npc)
  7. leftleg.Size = Vector3.new(1, 2, 1)
  8. leftleg.formFactor = "Symmetric"
  9. local rightarm = Instance.new("Part", npc)
  10. rightarm.Size = Vector3.new(1, 2, 1)
  11. rightarm.formFactor = "Symmetric"
  12. local rightleg = Instance.new("Part", npc)
  13. rightleg.Size = Vector3.new(1, 2, 1)
  14. rightleg.formFactor = "Symmetric"
  15. local torso = Instance.new("Part", npc)
  16. torso.Size = Vector3.new(2, 2, 1)
  17. torso.formFactor = "Symmetric"
  18. local head = Instance.new("Part", npc)
  19. head.Size = Vector3.new(2, 1, 1)
  20. head.formFactor = "Symmetric"
  21. local joints = {}
  22. local canRespawn = true
  23. local stance = "idle"
  24. local cachecopy = npc:Clone()
  25.  
  26. function MakeHuman()
  27. local h = Instance.new("Humanoid")
  28. h.MaxHealth = 100
  29. h.Health = 100
  30. h.WalkSpeed = 16
  31. h.Parent = npc
  32. end
  33.  
  34. function ConnectWithInstance(instance)
  35.  
  36. local c = Instance.new(instance)
  37. c.Part0 = torso
  38. c.Part1 = head
  39. c.C1 = c.Part1.CFrame:toObjectSpace(c.Part0.CFrame)
  40. c.Name = "HeadConnector"
  41. joints[c.Name] = c
  42. c.Parent = game.JointsService
  43. c = nil
  44.  
  45. local c = Instance.new(instance)
  46. c.Part0 = torso
  47. c.Part1 = leftarm
  48. c.C0 = CFrame.new(-1.5,.5,0) * CFrame.Angles(math.rad(90),math.rad(90),math.rad(90))
  49. c.C1 = CFrame.new(0,-.5,0)
  50. c.Name = "LeftArmConnector"
  51. c.MaxVelocity = .15
  52. joints[c.Name] = c
  53. c.Parent = game.JointsService
  54. c = nil
  55.  
  56. local c = Instance.new(instance)
  57. c.Part0 = torso
  58. c.Part1 = leftleg
  59. c.C0 = CFrame.new(-.5,-1.5,0) * CFrame.Angles(math.rad(90),math.rad(90),math.rad(90))
  60. c.C1 = CFrame.new(0,-.5,0)
  61. c.Name = "LeftLegConnector"
  62. c.MaxVelocity = .15
  63. joints[c.Name] = c
  64. c.Parent = game.JointsService
  65. c = nil
  66.  
  67. local c = Instance.new(instance)
  68. c.Part0 = torso
  69. c.Part1 = rightarm
  70. c.C0 = CFrame.new(1.5,.5,0) * CFrame.Angles(math.rad(90),math.rad(90),math.rad(90))
  71. c.C1 = CFrame.new(0,-.5,0)
  72. c.Name = "RightArmConnector"
  73. c.MaxVelocity = .15
  74. joints[c.Name] = c
  75. c.Parent = game.JointsService
  76. c = nil
  77.  
  78. local c = Instance.new(instance)
  79. c.Part0 = torso
  80. c.Part1 = rightleg
  81. c.C0 = CFrame.new(.5,-1.5,0) * CFrame.Angles(math.rad(90),math.rad(90),math.rad(90))
  82. c.C1 = CFrame.new(0,-.5,0)
  83. c.Name = "RightLegConnector"
  84. c.MaxVelocity = .15
  85. joints[c.Name] = c
  86. c.Parent = game.JointsService
  87. c = nil
  88.  
  89. end
  90.  
  91. function UnAnchor()
  92. for i,v in pairs(npc:GetChildren()) do
  93. if v:IsA("Part") then
  94. v.Anchored = false
  95. end
  96. end
  97. end
  98.  
  99. function AnimateFrame(time)
  100. local a
  101. local f
  102. local ca = 0
  103. if stance == "idle" then
  104. joints["RightArmConnector"].MaxVelocity = .15
  105. joints["LeftArmConnector"].MaxVelocity = .15
  106. a = .1
  107. f = 1
  108. elseif stance == "running" then
  109. joints["RightArmConnector"].MaxVelocity = .15
  110. joints["LeftArmConnector"].MaxVelocity = .15
  111. a = 1
  112. f = 9
  113. elseif stance == "jumping" then
  114. joints["RightArmConnector"].MaxVelocity = .5
  115. joints["LeftArmConnector"].MaxVelocity = .5
  116. joints["RightArmConnector"].DesiredAngle = 3.14
  117. joints["LeftArmConnector"].DesiredAngle = 3.14
  118. joints["RightLegConnector"].DesiredAngle = 0
  119. joints["LeftLegConnector"].DesiredAngle = 0
  120. return
  121. elseif stance == "climbing" then
  122. joints["RightArmConnector"].MaxVelocity = .5
  123. joints["LeftArmConnector"].MaxVelocity = .5
  124. a = 1
  125. f = 9
  126. ca = 3.14
  127. elseif stance == "sitting" then
  128. joints["RightArmConnector"].MaxVelocity = .15
  129. joints["LeftArmConnector"].MaxVelocity = .15
  130. joints["RightArmConnector"].DesiredAngle = 0
  131. joints["LeftArmConnector"].DesiredAngle = 0
  132. joints["RightLegConnector"].DesiredAngle = 1.57
  133. joints["LeftLegConnector"].DesiredAngle = 1.57
  134. return
  135. end
  136. local da = a * math.sin(time*f)
  137. joints["RightArmConnector"].DesiredAngle = -da - ca
  138. joints["LeftArmConnector"].DesiredAngle = da + ca
  139. joints["RightLegConnector"].DesiredAngle = da
  140. joints["LeftLegConnector"].DesiredAngle = -da
  141. end
  142.  
  143. ConnectWithInstance("Motor6D")
  144. MakeHuman()
  145. UnAnchor()
  146.  
  147. npc.Humanoid.Running:connect(function(speed)
  148. if speed > 0 then
  149. stance = "running"
  150. else
  151. stance = "idle"
  152. end
  153. end)
  154.  
  155. npc.Humanoid.Jumping:connect(function()
  156. stance = "jumping"
  157. end)
  158.  
  159. npc.Humanoid.FreeFalling:connect(function()
  160. stance = "jumping" -- On purpose!
  161. end)
  162.  
  163. npc.Humanoid.Seated:connect(function()
  164. stance = "sitting"
  165. end)
  166.  
  167. coroutine.wrap(function()
  168. while true do
  169. local gt,time = wait()
  170. AnimateFrame(time)
  171. end
  172. end)()
  173.  
  174.  
  175.  
  176.  
  177. -- Custom Code Below
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement