Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --robot chase
- force_player_speed_40=true
- soundid=132947307
- robothealth=100
- robotspeed=45
- robotbase=8
- robotbaseheight=5
- robotbasecolor="Black"
- robothead=4
- robotheadheight=2
- robotheadcolor="Bright red"
- dps=20
- dmgradius=4
- snd=Instance.new"Sound"
- snd.Parent=workspace
- snd.Volume=.5
- snd.SoundId="rbxassetid://"..soundid
- snd.Looped=true
- snd:Play()
- bots=0
- math.randomseed(tick())
- function createBot()
- bots=bots+1
- local basebot=Instance.new"Model"
- local base=Instance.new"Part"
- base.Parent=basebot
- base.Name="Torso"
- base.FormFactor="Custom"
- base.Size=Vector3.new(robotbase, robotbaseheight, robotbase)
- base.BrickColor=BrickColor.new(robotbasecolor)
- base.Position=Vector3.new(math.random(-5, 5)*35 + (35/2), 5, math.random(-5, 5)*35 + (35/2))
- local head=Instance.new"Part"
- head.Parent=basebot
- head.Name="Head"
- head.FormFactor="Custom"
- head.Size=Vector3.new(robothead, robotheadheight, robothead)
- head.BrickColor=BrickColor.new(robotheadcolor)
- head.TopSurface="Smooth"
- head.Position=base.Position+Vector3.new(0,((robotbaseheight+robotheadheight)/2),0)
- basebot.Parent=workspace.Base
- basebot:MakeJoints()
- local h=Instance.new"Humanoid"
- h.MaxHealth=robothealth
- h.Health=robothealth
- h.WalkSpeed=robotspeed
- h.Parent=basebot
- basebot.Name="Robot Police"
- local dsnd=Instance.new("Sound", head)
- dsnd.SoundId="rbxassetid://145486927"
- dsnd.Volume=1
- local dsnd2=Instance.new("Sound", head)
- dsnd2.SoundId="rbxassetid://145486927"
- dsnd2.Volume=1
- local dsnd3=Instance.new("Sound", head)
- dsnd3.SoundId="rbxassetid://145486927"
- dsnd3.Volume=1
- local con
- head.Touched:connect(function(hit)
- con:disconnect()
- for _, p in ipairs(game:GetService"Players":GetPlayers()) do
- if p.Character and p.Character:IsAncestorOf(hit) and h.Health~=0 then
- h.Health=0
- dsnd:Play() --layer sound to make it louder
- dsnd2:Play()
- dsnd3:Play()
- head.CanCollide=false
- base.CanCollide=false
- game:GetService"Debris":AddItem(basebot, 1)
- bots=bots-1
- for i=0, .9, 1/10 do
- wait(.1)
- head.Transparency=i
- base.Transparency=i
- end
- createBot()
- break;
- end
- end
- end)
- local function getnp(np)
- local nearval=math.huge
- local nearplayer=nil
- for _, p in ipairs(game:GetService"Players":GetPlayers()) do
- if p.Character and p:DistanceFromCharacter(base.Position)<nearval then
- nearplayer=p
- nearval=p:DistanceFromCharacter(base.Position)
- end
- end
- return nearplayer
- end
- local currplayer=getnp()
- con=game:GetService"RunService".Stepped:connect(function(_,dt)
- if not currplayer or not currplayer.Character or not (currplayer.Character.Humanoid.Health>0) or not currplayer.Character:FindFirstChild"Torso" then
- currplayer=getnp()
- end
- if currplayer:DistanceFromCharacter(base.Position)>50 and getnp() then
- currplayer=getnp()
- end
- if currplayer and not (currplayer:DistanceFromCharacter(base.Position)>200) then
- h:MoveTo(currplayer.Character.Torso.Position)
- end
- if currplayer:DistanceFromCharacter(base.Position)<robotbase+dmgradius then
- currplayer.Character.Humanoid:TakeDamage(dps*dt)
- end
- end)
- return basebot
- end
- for _, p in ipairs(game:GetService"Players":GetPlayers()) do
- if p.Character and p.Character:FindFirstChild"Humanoid" then
- p.Character.Humanoid.WalkSpeed=40
- end
- end
- if force_player_speed_40 then
- game:GetService"RunService".Stepped:connect(function()
- for _, p in ipairs(game:GetService"Players":GetPlayers()) do
- if p.Character and p.Character:FindFirstChild"Humanoid" then
- p.Character.Humanoid.WalkSpeed=40
- end
- end
- end)
- end
- for x=-5, 5 do
- for z=-5, 5 do
- if not (x==0 and z==0) then
- local p=Instance.new("Part", workspace.Base)
- local height=math.random(50, 100)
- p.Anchored=true
- if math.random(1, 5)==1 then
- p.BrickColor=BrickColor.new"Bright red"
- p.Velocity=Vector3.new(0, 500, 0)
- end
- p.Locked=true
- p.Position=Vector3.new(x*35, height/2, z*35)
- p.Size=Vector3.new(10, height, 10)
- end
- end
- end
- createBot()
- createBot()
- createBot()
- createBot()
- createBot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement