Advertisement
pitrioptixiop

Roblox | My bodyguard script

Feb 25th, 2018
2,282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.69 KB | None | 0 0
  1. --made by retrojooooono duh
  2. lp = game.Players.LocalPlayer
  3. char = lp.Character
  4. head = char.Head
  5. followmouse = false
  6. gunsout = false
  7. hum = char:FindFirstChildOfClass("Humanoid")
  8. agentnames = {"Andy","Oliver","Xavier","David","Bob","John","Fred","Greg","George","Peter","Paul","Christopher","Luke"}
  9. bodyguards = {}
  10. function makeagent(name)
  11. char.Archivable = true
  12. clone = char:Clone()
  13. clone.Parent = workspace
  14. clone.Name = name
  15. gc = clone:GetChildren()
  16. for i=1, #gc do
  17. if gc[i].ClassName == "Shirt" or gc[i].ClassName == "Pants" or gc[i].ClassName == "Accessory" or gc[i].ClassName == "Hat" or gc[i].ClassName == "ShirtGraphic" or gc[i].ClassName == "ShirtGraphics" then
  18. gc[i]:Destroy()
  19. end
  20. end
  21. findbc = clone:FindFirstChildOfClass("BodyColors")
  22. if findbc then
  23. findbc:Destroy()
  24. end
  25. newbc = Instance.new("BodyColors",clone)
  26. newbc.HeadColor = BrickColor.new("Buttermilk")
  27. newbc.LeftArmColor = BrickColor.new("Medium stone grey")
  28. newbc.RightArmColor = BrickColor.new("Medium stone grey")
  29. newbc.TorsoColor = BrickColor.new("Medium stone grey")
  30. newbc.LeftLegColor = BrickColor.new("Really black")
  31. newbc.RightLegColor = BrickColor.new("Really black")
  32. clone.Head:FindFirstChildOfClass("Decal").Texture = "rbxasset://textures/face.png"
  33. game:GetService("Chat"):Chat(clone.Head, "Agent "..clone.Name.." is in the area.", Enum.ChatColor.White)
  34. table.insert(bodyguards, clone)
  35. end
  36. print([[
  37. retrojooooono's bodyguard script
  38. inspired by mustardfoot's bodyguard script
  39. Commands:
  40. bg/enter area -- Spawns a bodyguard.
  41. bg/enter area/[number] -- Replace [number]
  42. with a number. This will spawn [number] amount of
  43. bodyguards.
  44. bg/leave area -- Removes all bodyguards.
  45. bg/follow mouse -- Toggles if the bodyguards
  46. will follow the mouse or follow your character.
  47. bg/chat/[msg] -- Replace "[msg]" with a message.
  48. bg/guns out -- Makes bodyguards bring out their guns
  49. and become ready to shoot someone. When the bodyguards'
  50. guns are out you can hold the left mouse button to
  51. make them shoot to where your mouse is pointing.
  52. Has a 1 to 10 chance that the shot brick
  53. will be destroyed. Will hurt NPCs, bodyguards,
  54. and player characters that you shoot at.
  55. bg/guns away -- Makes bodyguards hide their guns.
  56. All of your bodyguards will say the message.
  57. ]])
  58. lp.Chatted:connect(function(msg)
  59. if msg == "bg/enter area" then
  60. makeagent(agentnames[math.random(1,#agentnames)])
  61. end
  62. if string.sub(msg,1,14) == "bg/enter area/" then
  63. howmuchtospawn = tonumber(string.sub(msg,15))
  64. for spawnnumber=1, howmuchtospawn do
  65. wait(0.01)
  66. makeagent(agentnames[math.random(1,#agentnames)])
  67. end
  68. end
  69. if msg == "bg/leave area" then
  70. for get=1, #bodyguards do
  71. curbg = bodyguards[get]
  72. curbg:Destroy()
  73. end
  74. end
  75. if msg == "bg/follow mouse" then
  76. if followmouse then
  77. followmouse = false
  78. else
  79. followmouse = true
  80. end
  81. end
  82. if string.sub(msg,1,8) == "bg/chat/" then
  83. if string.len(msg) > 8 then
  84. whattochat = string.sub(msg,9)
  85. for chat=1, #bodyguards do
  86. if bodyguards[chat] ~= nil then
  87. if bodyguards[chat]:FindFirstChild("Head") then
  88. wait(0.01)
  89. game:GetService("Chat"):Chat(bodyguards[chat]:FindFirstChild("Head"), whattochat, Enum.ChatColor.White)
  90. end
  91. end
  92. end
  93. end
  94. end
  95. if msg == "bg/guns out" then
  96. for gun=1, #bodyguards do
  97. wait(0.01)
  98. gunsout = true
  99. guntool = Instance.new("Tool")
  100. guntool.Name = "Gun"
  101. handle = Instance.new("Part",guntool)
  102. handle.Name = "Handle"
  103. handle.Size = Vector3.new(3,1,1)
  104. handle.FrontSurface = Enum.SurfaceType.Hinge
  105. guntool.Parent = bodyguards[gun]
  106. end
  107. end
  108. if msg == "bg/guns away" then
  109. for nogun=1, #bodyguards do
  110. wait(0.01)
  111. if bodyguards[nogun]:FindFirstChild("Gun") then
  112. bodyguards[nogun]:FindFirstChild("Gun"):Destroy()
  113. gunsout = false
  114. end
  115. end
  116. end
  117. end)
  118. lp:GetMouse().Button1Down:connect(function()
  119. wait(0.01)
  120. mouse = lp:GetMouse()
  121. hit = mouse.Hit
  122. if gunsout then
  123. target = mouse.Target
  124. for shoot=1, #bodyguards do
  125. bghead = bodyguards[shoot]:FindFirstChild("Head")
  126. if bghead then
  127. bullet = Instance.new("Part",workspace)
  128. bullet.Size = Vector3.new(0.25,0.25,0.25)
  129. bullet.CFrame = mouse.Hit
  130. bullet.BrickColor = BrickColor.Black()
  131. sound = Instance.new("Sound",bullet)
  132. sound.SoundId = "rbxassetid://130770091"
  133. sound:Play()
  134. if target.Parent:FindFirstChildOfClass("Humanoid") then
  135. target.Parent:FindFirstChildOfClass("Humanoid"):TakeDamage(5)
  136. end
  137. if math.random(1,10) == 5 then
  138. target:Destroy()
  139. end
  140. end
  141. end
  142. end
  143. end)
  144. while true do
  145. wait(1)
  146. for a=1, #bodyguards do
  147. if bodyguards[a] ~= nil then
  148. if bodyguards[a]:FindFirstChild("Head") then
  149. if followmouse == false then
  150. bodyguards[a]:FindFirstChildOfClass("Humanoid").WalkToPoint = head.Position
  151. else
  152. bodyguards[a]:FindFirstChildOfClass("Humanoid").WalkToPoint = Vector3.new(lp:GetMouse().Hit.X, lp:GetMouse().Hit.Y, lp:GetMouse().Hit.Z)
  153. end
  154. end
  155. end
  156. end
  157. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement