Advertisement
clockwatcher00f

for nanobots

Aug 3rd, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.62 KB | None | 0 0
  1. --Particle Slime by timwood1104--
  2. -- Particle Slime is an interesting concept of Roblox enemy completely designed and built by
  3. -- timwood1104(aka, me). Originally inspired by an episode from Star Treck, I designed this using the
  4. -- .magnitude as a way to determine which slime particle is closest and farthest away from the target.
  5. -- To move closer to the target, the slime takes the particle farthest away and puts it in a random
  6. -- position closer to the target it is chasing. This causes the slime to move slowly, but surely towards it's
  7. -- prey. Obviously, the slime has no Humanoid, meaning that it can't be killed unless somebody
  8. -- constructs a specific tool to do so. Remember, I made this first! Enjoy :P
  9.  
  10. -------------
  11. spaces = 2 -- How many spaces it travels per move(1-3 is the best, preferably 2)
  12. speed = 1000000000 -- How fast it goes, just put any number I guess :P
  13. grabslime = true -- Whether the slime will grab Slimeys from Workspace or not; it doesn't affect much
  14. ------------- though. Basically, if there is any bricks in Workspace named "Slimey", it will add them to itself.
  15.  
  16.  
  17. function findTarget() -- Ah, the findTarget() command. This command lets the slime find it's next victem.
  18. g = game.Workspace:getChildren()
  19. for i=1, #g do
  20. if g[i]:findFirstChild("Torso") ~= nil then
  21. if T == nil then
  22. T = g[i].Torso
  23. else
  24. if (g[i].Torso.Position - script.Parent.Slimey.Position).magnitude < (T.Position - script.Parent.Slimey.Position).magnitude then
  25. T = g[i].Torso
  26. end
  27. end
  28. end
  29. if grabslime == true and g[i].Name == "Slimey" and g[i].className == "Part" and g[i].Size == Vector3.new(1,1,1) then
  30. g[i].Parent = script.Parent
  31. end
  32. end
  33. end
  34.  
  35. function fade(b)-- This lets a brick disappear by "fading" into invisibility, but you can't see the effect very
  36. while b.Transparency < 1 do-- easily unless the slime is at a slow speed.
  37. b.Transparency = b.Transparency + 0.01*speed*#p/4
  38. wait(0.001)
  39. end
  40. b.Transparency = 1
  41. end
  42.  
  43. function unfade(b) -- This lets a brick appear by "fading" into visibility, but you can't see the effect very
  44. while b.Transparency > 0 do -- easily unless the slime is at a slow speed.
  45. b.Transparency = b.Transparency - 0.01*speed*#p/4
  46. wait(0.001)
  47. end
  48. b.Transparency = 0
  49. end
  50.  
  51. while true do
  52.  
  53. T = nil -- Erases previous target from memory.
  54. findTarget() -- Finds the new closest target!
  55.  
  56. r = math.random(1,20) --This little bit is supposed to allow the slime to take bigger "steps" every
  57. if r == 1 or r == 2 or r == 3 then -- once and a while, thus allowing it to travel through thick walls.
  58. space = spaces + 1
  59. elseif r == 4 or r == 5 then
  60. space = spaces + 2
  61. elseif r == 6 then
  62. space = spaces + 3
  63. else
  64. space = spaces
  65. end
  66.  
  67. if T ~= nil then --If target exists, then attack!
  68. p = script.Parent:getChildren() -- Makes a list of the slime's "Slimeys"
  69. for i=1, #p do
  70. if p[i].Name == "Slimey" then
  71. if prev == nil then
  72. prev = p[i]
  73. prev2 = p[i]
  74. end
  75. if (p[i].Position - T.Position).magnitude > (prev.Position - T.Position).magnitude then
  76. prev = p[i] -- This finds the Slimey closest to the target.
  77. end
  78. if (p[i].Position - T.Position).magnitude < (prev2.Position - T.Position).magnitude then
  79. prev2 = p[i] -- This finds the Slimey farthest away from the target.
  80. end
  81. end
  82. end
  83. fade(prev) --Make Slimey dissappear. VV- Make Slimey move closer to target.
  84. prev.Position = Vector3.new(prev2.Position.x+math.random(-space,space), prev2.Position.y-1, prev2.Position.z+math.random(-space,space))
  85. unfade(prev) -- Make Slimey appear again.
  86. end
  87. wait(0.01) -- And then wait... :P
  88. end -- Repeat!!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement