Advertisement
itchyzombie

dj's dope chase

Oct 24th, 2015
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.09 KB | None | 0 0
  1. --robot chase
  2.  
  3. force_player_speed_40=true
  4.  
  5. soundid=132947307
  6.  
  7. robothealth=100
  8. robotspeed=45
  9.  
  10. robotbase=8
  11. robotbaseheight=5
  12. robotbasecolor="Black"
  13.  
  14. robothead=4
  15. robotheadheight=2
  16. robotheadcolor="Bright red"
  17.  
  18. dps=20
  19. dmgradius=4
  20.  
  21. snd=Instance.new"Sound"
  22. snd.Parent=workspace
  23. snd.Volume=.5
  24. snd.SoundId="rbxassetid://"..soundid
  25. snd.Looped=true
  26. snd:Play()
  27. bots=0
  28. math.randomseed(tick())
  29. function createBot()
  30.     bots=bots+1
  31.     local basebot=Instance.new"Model"
  32.     local base=Instance.new"Part"
  33.     base.Parent=basebot
  34.     base.Name="Torso"
  35.     base.FormFactor="Custom"
  36.     base.Size=Vector3.new(robotbase, robotbaseheight, robotbase)
  37.     base.BrickColor=BrickColor.new(robotbasecolor)
  38.     base.Position=Vector3.new(math.random(-5, 5)*35 + (35/2), 5, math.random(-5, 5)*35 + (35/2))
  39.    
  40.     local head=Instance.new"Part"
  41.     head.Parent=basebot
  42.     head.Name="Head"
  43.     head.FormFactor="Custom"
  44.     head.Size=Vector3.new(robothead, robotheadheight, robothead)
  45.     head.BrickColor=BrickColor.new(robotheadcolor)
  46.     head.TopSurface="Smooth"
  47.    
  48.     head.Position=base.Position+Vector3.new(0,((robotbaseheight+robotheadheight)/2),0)
  49.    
  50.     basebot.Parent=workspace.Base
  51.     basebot:MakeJoints()
  52.     local h=Instance.new"Humanoid"
  53.     h.MaxHealth=robothealth
  54.     h.Health=robothealth
  55.     h.WalkSpeed=robotspeed
  56.     h.Parent=basebot
  57.     basebot.Name="Robot Police"
  58.    
  59.     local dsnd=Instance.new("Sound", head)
  60.     dsnd.SoundId="rbxassetid://145486927"
  61.     dsnd.Volume=1
  62.    
  63.     local dsnd2=Instance.new("Sound", head)
  64.     dsnd2.SoundId="rbxassetid://145486927"
  65.     dsnd2.Volume=1
  66.    
  67.     local dsnd3=Instance.new("Sound", head)
  68.     dsnd3.SoundId="rbxassetid://145486927"
  69.     dsnd3.Volume=1
  70.     local con
  71.     head.Touched:connect(function(hit)
  72.         con:disconnect()
  73.         for _, p in ipairs(game:GetService"Players":GetPlayers()) do
  74.             if p.Character and p.Character:IsAncestorOf(hit) and h.Health~=0 then
  75.                 h.Health=0
  76.                 dsnd:Play() --layer sound to make it louder
  77.                 dsnd2:Play()
  78.                 dsnd3:Play()
  79.                 head.CanCollide=false
  80.                 base.CanCollide=false
  81.                 game:GetService"Debris":AddItem(basebot, 1)
  82.                 bots=bots-1
  83.                 for i=0, .9, 1/10 do
  84.                     wait(.1)
  85.                     head.Transparency=i
  86.                     base.Transparency=i
  87.                 end
  88.                 createBot()
  89.                 break;
  90.             end
  91.         end
  92.     end)
  93.     local function getnp(np)
  94.         local nearval=math.huge
  95.         local nearplayer=nil
  96.         for _, p in ipairs(game:GetService"Players":GetPlayers()) do
  97.             if p.Character and p:DistanceFromCharacter(base.Position)<nearval then
  98.                 nearplayer=p
  99.                 nearval=p:DistanceFromCharacter(base.Position)
  100.             end
  101.         end
  102.         return nearplayer
  103.     end
  104.     local currplayer=getnp()
  105.    
  106.     con=game:GetService"RunService".Stepped:connect(function(_,dt)
  107.         if not currplayer or not currplayer.Character or not (currplayer.Character.Humanoid.Health>0) or not currplayer.Character:FindFirstChild"Torso" then
  108.             currplayer=getnp()
  109.         end
  110.         if currplayer:DistanceFromCharacter(base.Position)>50 and getnp() then
  111.             currplayer=getnp()
  112.         end
  113.         if currplayer and not (currplayer:DistanceFromCharacter(base.Position)>200) then
  114.             h:MoveTo(currplayer.Character.Torso.Position)
  115.         end
  116.         if currplayer:DistanceFromCharacter(base.Position)<robotbase+dmgradius then
  117.             currplayer.Character.Humanoid:TakeDamage(dps*dt)
  118.         end
  119.     end)
  120.     return basebot
  121. end
  122. for _, p in ipairs(game:GetService"Players":GetPlayers()) do
  123.     if p.Character and p.Character:FindFirstChild"Humanoid" then
  124.         p.Character.Humanoid.WalkSpeed=40
  125.     end
  126. end
  127. if force_player_speed_40 then
  128.     game:GetService"RunService".Stepped:connect(function()
  129.         for _, p in ipairs(game:GetService"Players":GetPlayers()) do
  130.             if p.Character and p.Character:FindFirstChild"Humanoid" then
  131.                 p.Character.Humanoid.WalkSpeed=40
  132.             end
  133.         end
  134.     end)
  135. end
  136.  
  137. for x=-5, 5 do
  138.     for z=-5, 5 do
  139.         if not (x==0 and z==0) then
  140.             local p=Instance.new("Part", workspace.Base)
  141.             local height=math.random(50, 100)
  142.             p.Anchored=true
  143.             if math.random(1, 5)==1 then
  144.              p.BrickColor=BrickColor.new"Bright red"
  145.             p.Velocity=Vector3.new(0, 500, 0)
  146.             end
  147.            
  148.             p.Locked=true
  149.             p.Position=Vector3.new(x*35, height/2, z*35)
  150.             p.Size=Vector3.new(10, height, 10) 
  151.         end
  152.     end
  153. end
  154.  
  155. createBot()
  156. createBot()
  157. createBot()
  158. createBot()
  159. createBot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement