Advertisement
billwa

Slime

Oct 24th, 2015
376
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.99 KB | None | 0 0
  1. slime = Instance.new("Model",game.Workspace)
  2. slime.Name = "slime"
  3.  
  4. blob2 = Instance.new("Part",slime)
  5. blob2.Velocity = Vector3.new(-1.7623788118362,-0.021285310387611,48.390308380127)
  6. blob2.FormFactor = Enum.FormFactor.Symmetric
  7. blob2.Elasticity = 0
  8. blob2.Transparency = 0.40000000596046
  9. blob2.TopSurface = Enum.SurfaceType.Smooth
  10. blob2.RotVelocity = Vector3.new(-0.043584678322077,-0.21588079631329,-0.041304044425488)
  11. blob2.Size = Vector3.new(8,8,8)
  12. blob2.Name = "Blob2"
  13. blob2.CFrame = CFrame.new(86.441627502441,3.9890384674072,-50.019386291504) * CFrame.Angles(2.7670059204102, 0.72412210702896, -2.8864076137543)
  14. blob2.BrickColor = BrickColor.new("Bright green")
  15. blob2.Friction = 0
  16. blob2.Shape = Enum.PartType.Ball
  17. blob2.BottomSurface = Enum.SurfaceType.Smooth
  18.  
  19. blob1 = Instance.new("Part",slime)
  20. blob1.Velocity = Vector3.new(-1.7623788118362,-0.021285310387611,48.390308380127)
  21. blob1.FormFactor = Enum.FormFactor.Symmetric
  22. blob1.LeftSurface = Enum.SurfaceType.Glue
  23. blob1.Elasticity = 0
  24. blob1.TopSurface = Enum.SurfaceType.Glue
  25. blob1.RotVelocity = Vector3.new(-0.043584678322077,-0.21588079631329,-0.041304044425488)
  26. blob1.Size = Vector3.new(3,3,3)
  27. blob1.Name = "Blob1"
  28. blob1.FrontSurface = Enum.SurfaceType.Glue
  29. blob1.CFrame = CFrame.new(86.441627502441,3.9890384674072,-50.019386291504) * CFrame.Angles(2.7670059204102, 0.72412204742432, -2.8864076137543)
  30. blob1.RightSurface = Enum.SurfaceType.Glue
  31. blob1.BackSurface = Enum.SurfaceType.Glue
  32. blob1.BrickColor = BrickColor.new("Bright green")
  33. blob1.Friction = 0
  34. blob1.Shape = Enum.PartType.Ball
  35. blob1.BottomSurface = Enum.SurfaceType.Glue
  36.  
  37. mesh = Instance.new("SpecialMesh",blob1)
  38. mesh.Scale = Vector3.new(0.69999998807907,0.69999998807907,0.69999998807907)
  39. mesh.MeshType = Enum.MeshType.Sphere
  40.  
  41. speed = Instance.new("NumberValue",blob2)
  42. speed.Name = "Speed"
  43. speed.Value = 0.2
  44.  
  45. bodygyro = Instance.new("BodyGyro",blob2)
  46. bodygyro.maxTorque = Vector3.new(9000,9000,9000)
  47. bodygyro.cframe = CFrame.new(85.811500549316,4.2727932929993,-50.957424163818) * CFrame.Angles(2.7415568828583, 0.75453597307205, -2.8596844673157)
  48.  
  49. bodyposition = Instance.new("BodyPosition",blob2)
  50. bodyposition.maxForce = Vector3.new(2000,2000,2000)
  51. bodyposition.position = Vector3.new(-6.4771208763123,42.504699707031,39.460441589355)
  52.  
  53. weld = Instance.new("Weld",blob2)
  54. weld.Part1 = Blob2
  55. weld.Part0 = Blob1
  56. weld.C1 = CFrame.new(0,0,0) * CFrame.Angles(-0.56438058614731, 1.3102374076843, 0.0021327317226678)
  57. weld.C0 = CFrame.new(0,0,0) * CFrame.Angles(-0.56438058614731, 1.3102374076843, 0.0021327317226678)
  58.  
  59. speed = Instance.new("NumberValue",slime)
  60. speed.Name = "Speed"
  61. speed.Value = 0.2
  62.  
  63. bodygyro = Instance.new("BodyGyro",slime)
  64. bodygyro.maxTorque = Vector3.new(9000,9000,9000)
  65. bodygyro.cframe = CFrame.new(78.518280029297,2.7634258270264,20.855653762817) * CFrame.Angles(2.7586266994476, 3.0517565392074e-005, -3.1415803432465)
  66.  
  67. bodyposition = Instance.new("BodyPosition",slime)
  68. bodyposition.maxForce = Vector3.new(2000,2000,2000)
  69. bodyposition.position = Vector3.new(78.51823425293,3.3874299526215,22.40460395813)
  70.  
  71. speed = Instance.new("NumberValue",slime)
  72. speed.Name = "Speed"
  73. speed.Value = 0.2
  74.  
  75. bodygyro = Instance.new("BodyGyro",slime)
  76. bodygyro.maxTorque = Vector3.new(9000,9000,9000)
  77. bodygyro.cframe = CFrame.new(78.520431518555,2.7606685161591,21.012775421143) * CFrame.Angles(2.761394739151, -0.00064849876798689, 3.1413335800171)
  78.  
  79. bodyposition = Instance.new("BodyPosition",slime)
  80. bodyposition.maxForce = Vector3.new(2000,2000,2000)
  81. bodyposition.position = Vector3.new(78.521507263184,3.3747184276581,22.549276351929)
  82.  
  83. local prev
  84. local parts = slime:GetChildren()
  85.  
  86. for i = 1,#parts do
  87.         if (parts[i].className == "Part") then
  88.                 if (prev ~= nil)then
  89.                         local weld = Instance.new("Weld")
  90.                         weld.Part0 = prev
  91.                         weld.Part1 = parts[i]
  92.                         weld.C0 = prev.CFrame:inverse()
  93.                         weld.C1 = parts[i].CFrame:inverse()
  94.                         weld.Parent = prev
  95.                 end
  96.                 prev = parts[i]
  97.         end
  98. end
  99.  
  100. bin = slime
  101.  
  102. function move(target)
  103.     local dir = (target.Position - bin.Position).unit
  104.     local spawnPos = bin.Position
  105.     local pos = spawnPos + (dir * 1)
  106.     bin:findFirstChild("BodyGyro").cframe = CFrame.new(pos,  pos + dir)
  107.     bin:findFirstChild("BodyGyro").maxTorque = Vector3.new(9000,9000,9000)
  108. end
  109.  
  110. function moveTo(target)
  111.     bin.BodyPosition.position = target.Position
  112.     bin.BodyPosition.maxForce = Vector3.new(10000,10000,10000) * bin.Speed.Value
  113. end
  114.  
  115. function findNearestTorso(pos)
  116.     local list = game.Workspace:GetChildren()
  117.     local torso = nil
  118.     local dist = 1000
  119.     local temp = nil
  120.     local human = nil
  121.     local temp2 = nil
  122.     for x = 1, #list do
  123.         temp2 = list[x]
  124.         if (temp2.className == "Model") and (temp2 ~= slime) then
  125.             temp = temp2:findFirstChild("Torso")
  126.             human = temp2:findFirstChild("Humanoid")
  127.             if (temp ~= nil) and (human ~= nil) and (human.Health > 0)  then
  128.                 if (temp.Position - pos).magnitude < dist then
  129.                     torso = temp
  130.                     dist = (temp.Position - pos).magnitude
  131.                 end
  132.             end
  133.         end
  134.     end
  135.     return torso
  136. end
  137.  
  138. function shoot(pos)
  139.     dir = (pos - bin.CFrame.p).unit
  140.     for i = 1, 50 do
  141.         local ex = Instance.new("Explosion")
  142.         ex.BlastRadius = 1
  143.         ex.Position = bin.Position + (dir * 10 * i) + (dir * 7)
  144.         ex.Parent = game.Workspace
  145.     end
  146. end
  147.  
  148. function shootAt(torso)
  149.     local dir = (torso.Position - bin.Position).unit
  150.     local spawnPos = bin.Position
  151.     local pos = spawnPos + (dir * 1)
  152.     shoot(pos)
  153. end
  154.  
  155. while true do
  156.     local torso = findNearestTorso(bin.Position)
  157.     if torso~=nil then
  158.         move(torso)
  159.         moveTo(torso)
  160.     end
  161.     wait()
  162. end
  163.  
  164. function Stick(A,B)
  165. A.CFrame = B.CFrame
  166.     local weld = Instance.new("Weld")
  167.  
  168.     weld.Part0 = A
  169.  
  170.     weld.Part1 = B
  171.  
  172.     local HitPos = B.Position
  173.  
  174.     local CJ = CFrame.new(HitPos)
  175.  
  176.     local C0 = B.CFrame:inverse() *CJ
  177.  
  178.     local C1 = A.CFrame:inverse() * CJ
  179.  
  180.     weld.C0 = C0
  181.  
  182.     weld.C1 = C1
  183.  
  184.     weld.Parent = B
  185.  
  186. end
  187. Stick(slime.Blob1,slime.Blob2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement