Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Particle Slime by timwood1104--
- -- Particle Slime is an interesting concept of Roblox enemy completely designed and built by
- -- timwood1104(aka, me). Originally inspired by an episode from Star Treck, I designed this using the
- -- .magnitude as a way to determine which slime particle is closest and farthest away from the target.
- -- To move closer to the target, the slime takes the particle farthest away and puts it in a random
- -- position closer to the target it is chasing. This causes the slime to move slowly, but surely towards it's
- -- prey. Obviously, the slime has no Humanoid, meaning that it can't be killed unless somebody
- -- constructs a specific tool to do so. Remember, I made this first! Enjoy :P
- -------------
- spaces = 2 -- How many spaces it travels per move(1-3 is the best, preferably 2)
- speed = 1000000000 -- How fast it goes, just put any number I guess :P
- grabslime = true -- Whether the slime will grab Slimeys from Workspace or not; it doesn't affect much
- ------------- though. Basically, if there is any bricks in Workspace named "Slimey", it will add them to itself.
- function findTarget() -- Ah, the findTarget() command. This command lets the slime find it's next victem.
- g = game.Workspace:getChildren()
- for i=1, #g do
- if g[i]:findFirstChild("Torso") ~= nil then
- if T == nil then
- T = g[i].Torso
- else
- if (g[i].Torso.Position - script.Parent.Slimey.Position).magnitude < (T.Position - script.Parent.Slimey.Position).magnitude then
- T = g[i].Torso
- end
- end
- end
- if grabslime == true and g[i].Name == "Slimey" and g[i].className == "Part" and g[i].Size == Vector3.new(1,1,1) then
- g[i].Parent = script.Parent
- end
- end
- end
- function fade(b)-- This lets a brick disappear by "fading" into invisibility, but you can't see the effect very
- while b.Transparency < 1 do-- easily unless the slime is at a slow speed.
- b.Transparency = b.Transparency + 0.01*speed*#p/4
- wait(0.001)
- end
- b.Transparency = 1
- end
- function unfade(b) -- This lets a brick appear by "fading" into visibility, but you can't see the effect very
- while b.Transparency > 0 do -- easily unless the slime is at a slow speed.
- b.Transparency = b.Transparency - 0.01*speed*#p/4
- wait(0.001)
- end
- b.Transparency = 0
- end
- while true do
- T = nil -- Erases previous target from memory.
- findTarget() -- Finds the new closest target!
- r = math.random(1,20) --This little bit is supposed to allow the slime to take bigger "steps" every
- if r == 1 or r == 2 or r == 3 then -- once and a while, thus allowing it to travel through thick walls.
- space = spaces + 1
- elseif r == 4 or r == 5 then
- space = spaces + 2
- elseif r == 6 then
- space = spaces + 3
- else
- space = spaces
- end
- if T ~= nil then --If target exists, then attack!
- p = script.Parent:getChildren() -- Makes a list of the slime's "Slimeys"
- for i=1, #p do
- if p[i].Name == "Slimey" then
- if prev == nil then
- prev = p[i]
- prev2 = p[i]
- end
- if (p[i].Position - T.Position).magnitude > (prev.Position - T.Position).magnitude then
- prev = p[i] -- This finds the Slimey closest to the target.
- end
- if (p[i].Position - T.Position).magnitude < (prev2.Position - T.Position).magnitude then
- prev2 = p[i] -- This finds the Slimey farthest away from the target.
- end
- end
- end
- fade(prev) --Make Slimey dissappear. VV- Make Slimey move closer to target.
- prev.Position = Vector3.new(prev2.Position.x+math.random(-space,space), prev2.Position.y-1, prev2.Position.z+math.random(-space,space))
- unfade(prev) -- Make Slimey appear again.
- end
- wait(0.01) -- And then wait... :P
- end -- Repeat!!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement