TheUnknownDiscord

turret

Nov 3rd, 2021 (edited)
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. debounce = false
  2. owner.Character.Head.Transparency = 1
  3. owner.Character.Humanoid:RemoveAccessories()
  4. local function customExplosion(position, radius, maxDamage)
  5. local explosion = Instance.new("Explosion")
  6. explosion.BlastPressure = 50 -- this could be set higher to still apply velocity to parts
  7. explosion.DestroyJointRadiusPercent = 0 -- joints are safe
  8. explosion.BlastRadius = radius
  9. explosion.Position = position
  10.  
  11. -- set up a table to track the models hit
  12. local modelsHit = {}
  13.  
  14. -- listen for contact
  15. explosion.Hit:Connect(function(part, distance)
  16. local parentModel = part.Parent
  17. if parentModel then
  18. -- check to see if this model has already been hit
  19. if modelsHit[parentModel] then
  20. return
  21. end
  22. -- log this model as hit
  23. modelsHit[parentModel] = true
  24.  
  25. -- look for a humanoid
  26. local humanoid = parentModel:FindFirstChild("Humanoid")
  27. if humanoid and humanoid ~= owner.Character.Humanoid then
  28. local distanceFactor = distance / explosion.BlastRadius -- get the distance as a value between 0 and 1
  29. distanceFactor = 1 - distanceFactor
  30. humanoid.Health = humanoid.Health - (maxDamage * distanceFactor)
  31. end
  32. end
  33. end)
  34.  
  35. explosion.Parent = game.Workspace
  36. local part1 = Instance.new("Part", script)
  37. part1.Size = Vector3.new(15, 15, 15)
  38. part1.Position = position
  39. part1.CanCollide = false
  40. part1.Anchored = true
  41. part1.Material = "Neon"
  42. part1.BrickColor = BrickColor.new("New Yeller")
  43. part1.Transparency = 0.5
  44. game:GetService("Debris"):AddItem(part1,0.5)
  45. for i = 1, 10 do
  46. wait(0.0885)
  47. part1.CFrame = part1.CFrame * CFrame.Angles(math.rad(math.random(-360,360)),math.rad(math.random(-360,360)),math.rad(math.random(-360,360)))
  48. end
  49. end
  50. Brick = Instance.new("Part", owner.Character)
  51. Brick.Size = Vector3.new(1,1,2.5)
  52. Brick.Material = Enum.Material.SmoothPlastic
  53. Brick.CFrame = owner.Character.HumanoidRootPart.CFrame* CFrame.new(0,-0.25,5)
  54. Brick:SetNetworkOwner(owner)
  55. Brick.Name = "Block"
  56. Brick.CanCollide = false
  57. Brick2 = Instance.new("Part", owner.Character)
  58. Brick2.Size = Vector3.new(1.5,2,1.5)
  59. Brick2.Material = Enum.Material.SmoothPlastic
  60. Brick2.CFrame = owner.Character.HumanoidRootPart.CFrame * CFrame.new(0,-1.25,5)
  61. Brick2:SetNetworkOwner(owner)
  62. Brick2.Name = "Block2"
  63. Brick3 = Instance.new("Part", owner.Character)
  64. Brick3.Size = Vector3.new(1,1,1)
  65. Brick3.Material = Enum.Material.SmoothPlastic
  66. Brick3.CFrame = owner.Character.HumanoidRootPart.CFrame * CFrame.new(0,0.25,0.375)
  67. Brick3:SetNetworkOwner(owner)
  68. Brick3.Name = "Block3"
  69. Brick3.CanCollide = false
  70. Brick3.Transparency = 1
  71. Brick3.Massless = true
  72. Brick2.Massless = true
  73. Brick.Massless = true
  74. local density = 0.5
  75. local friction = 0.5
  76. local elasticity = 1
  77. local frictionWeight = 0
  78. local elasticityWeight = 100000000000
  79. local physProperties = PhysicalProperties.new(density, friction, elasticity, frictionWeight, elasticityWeight)
  80. local b = Instance.new("BodyVelocity",Brick)
  81. b.MaxForce = Vector3.new(500000,500000,500000)
  82. b.Velocity = Vector3.new()
  83. gun = Instance.new("RemoteEvent",owner.Character)
  84. gun.Name = "the thing you shoot"
  85. explodemode = false
  86. gun.OnServerEvent:Connect(function(plr, action)
  87. if action == "explodemode" then
  88. explodemode = true
  89. elseif action == "Normal" then
  90. explodemode = false
  91. end
  92. if action == "shoot" then
  93. local bullet = Instance.new("SpawnLocation",script)
  94. bullet.Enabled = false
  95. bullet.CFrame = Brick.CFrame * CFrame.new(0,0,-5)
  96. bullet.Size = Vector3.new(0.75,0.75,2.5)
  97. bullet.Material = Enum.Material.SmoothPlastic
  98. bullet.CustomPhysicalProperties = physProperties
  99. if explodemode then
  100. bullet.BrickColor = BrickColor.new("Bright red")
  101. game:GetService("Debris"):AddItem(bullet,5)
  102. bullet:ApplyImpulse(bullet.CFrame.lookVector * 165)
  103. elseif not explodemode then
  104. bullet.BrickColor = BrickColor.new("New Yeller")
  105. game:GetService("Debris"):AddItem(bullet,7.5)
  106. bullet:ApplyImpulse(bullet.CFrame.lookVector * 200)
  107. end
  108. bullet.Touched:Connect(function(partlol)
  109. local partParent3 = partlol.Parent
  110. local humanoid = partParent3:FindFirstChildWhichIsA("Humanoid")
  111. if humanoid ~= owner.Character.Humanoid and humanoid then
  112. if not debounce then
  113. debounce = true
  114. if explodemode then
  115. customExplosion(bullet.Position,15,100)
  116. wait()
  117. bullet:Destroy()
  118. debounce = false
  119. elseif not explodemode then
  120. humanoid.Health = humanoid.Health - 35
  121. wait()
  122. bullet:Destroy()
  123. debounce = false
  124. end
  125. end
  126. end
  127. end)
  128. end
  129. end)
  130. Brickweld2 = Instance.new("NoCollisionConstraint",Brick2)
  131. Brickweld2.Part0 = Brick
  132. Brickweld2.Part1 = Brick2
  133. Brickweld = Instance.new("Weld",Brick2)
  134. Brickweld.Part0 = Brick3
  135. Brickweld.Part1 = Brick2
  136. Brickweld.C0 = CFrame.new(0,-1,0.375)
  137. local attachment0 = Instance.new("Attachment")
  138. attachment0.Parent = Brick2
  139. local attachment1 = Instance.new("Attachment")
  140. attachment1.Parent = owner.Character.Head
  141. alignposition = Instance.new("HingeConstraint")
  142. alignposition.Parent = owner.Character.Head
  143. alignposition.Attachment0 = attachment0
  144. alignposition.Attachment1 = attachment1
  145. attachment1.WorldCFrame = attachment1.Parent.CFrame * CFrame.new(0,0.75,0) * CFrame.Angles(0,0,math.rad(90))
  146. attachment0.WorldCFrame = attachment0.Parent.CFrame * CFrame.Angles(0,0,math.rad(90))
  147. NLS([[
  148. gun = owner.Character:WaitForChild("the thing you shoot")
  149. local mouse = owner:GetMouse()
  150. Brick = owner.Character:WaitForChild("Block")
  151. Brick2 = owner.Character:WaitForChild("Block2")
  152. Brick3 = owner.Character:WaitForChild("Block3")
  153. local bg = Instance.new("BodyGyro",Brick)
  154. bg.D = 100
  155. bg.P = 100000
  156. bg.MaxTorque = Vector3.new(1000000,1000000,1000000)
  157. game:GetService("RunService").RenderStepped:Connect(function()
  158. TweenService = game:GetService("TweenService")
  159. spininfo = TweenInfo.new(0.125,Enum.EasingStyle.Linear)
  160. spininfo2 = TweenInfo.new(0.125,Enum.EasingStyle.Linear)
  161. Spin1 = TweenService:Create(Brick2,spininfo,{CFrame = CFrame.new(Brick2.Position,Vector3.new(mouse.Hit.p.x,Brick2.Position.y,mouse.Hit.p.z))})
  162. Brick.Position = Brick3.Position
  163. Spin2 = TweenService:Create(bg,spininfo2,{CFrame = CFrame.new(Brick3.Position,Vector3.new(mouse.Hit.p.x,mouse.Hit.p.y,mouse.Hit.p.z))})
  164. Spin1:Play()
  165. Spin2:Play()
  166. end)
  167. MouseHold = false
  168. count = 0
  169. mouse.KeyDown:Connect(function(key)
  170. key = key:lower()
  171. if key == "e" then
  172. count = count + 1
  173. if count == 1 then
  174. gun:FireServer("explodemode")
  175. elseif count == 2 then
  176. gun:FireServer("Normal")
  177. task.wait()
  178. count = 0
  179. end
  180. end
  181. end)
  182. mouse.Button1Down:Connect(function()
  183. gun:FireServer("shoot")
  184. MouseHold = true
  185. end)
  186. mouse.Button1Up:Connect(function()
  187. MouseHold = false
  188. end)
  189. while true do
  190. wait(0.0625)
  191. if MouseHold then
  192. gun:FireServer("shoot")
  193. end
  194. end
  195. ]], owner.Character)
Add Comment
Please, Sign In to add comment