Advertisement
pan_pan20

Gobbler Script

Apr 18th, 2021
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.33 KB | None | 0 0
  1. local r = game:service("RunService");
  2.  
  3. local nextTime = 0
  4.  
  5. local vx = 0
  6. local vz = 2
  7.  
  8. local head = script.Parent
  9.  
  10. local poopCount = 0
  11.  
  12. function bounce()
  13.     head.Velocity = Vector3.new(math.random(40)-20,math.random(100),math.random(40)-20)
  14. end
  15.  
  16.  
  17. function gobble(part)
  18.     if (part.Name~="Base") and (part.Name~="Poop") then
  19.         part.Parent = nil
  20.         poopCount = poopCount + 1
  21.     end
  22.     bounce()
  23. end
  24.  
  25. head.Touched:connect(gobble)
  26.  
  27.  
  28. function move(time)
  29.  
  30.     -- Reduce RotVelocity
  31.     local v = head.RotVelocity
  32.     head.RotVelocity = Vector3.new(v.x/2,v.y/2,v.z/2)
  33.  
  34.  
  35.     -- Poop
  36.     if poopCount>0 then
  37.         local poop = Instance.new("Part")
  38.  
  39.         local p = head.Position
  40.         poop.Position = p
  41.         head.Position = Vector3.new(p.x, p.y+2, p.z)
  42.         poop.Size = Vector3.new(1,1,1)
  43.         poop.BrickColor = BrickColor.new(192)
  44.         poop.Name = "Poop"
  45.         poop.Parent = head.Parent
  46.  
  47.         poopCount = poopCount - 1
  48.     end
  49.  
  50.  
  51. end
  52.  
  53. bounce()
  54.  
  55. while head.Parent~=nil do
  56.  
  57.     time = r.Stepped:wait()
  58.  
  59.     local p = head.Position
  60.     if p.x>=30 then
  61.         head.Velocity = Vector3.new(-20, 20, 0)
  62.     elseif p.x<=-30 then
  63.         head.Velocity = Vector3.new(20, 20, 0)
  64.     end
  65.  
  66.     if p.z>=30 then
  67.         head.Velocity = Vector3.new(0, 20, -20)
  68.     elseif p.z<=-30 then
  69.         head.Velocity = Vector3.new(0, 20, 20)
  70.     end
  71.  
  72.    if time > nextTime then
  73.         move(time)
  74.         nextTime = time + 0.1
  75.     end
  76. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement