TheUnknownDiscord

turret

Nov 3rd, 2021 (edited)
89
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) -- TakeDamage to respect ForceFields
  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. bullet = Instance.new("Part",script)
  94. bullet.CFrame = Brick.CFrame * CFrame.new(0,0,-5)
  95. bullet.Size = Vector3.new(0.75,0.75,2.5)
  96. bullet.Material = Enum.Material.SmoothPlastic
  97. bullet.CustomPhysicalProperties = physProperties
  98. if explodemode then
  99. bullet.BrickColor = BrickColor.new("Bright red")
  100. game:GetService("Debris"):AddItem(bullet,5)
  101. bullet:ApplyImpulse(bullet.CFrame.lookVector * 165)
  102. elseif not explodemode then
  103. bullet.BrickColor = BrickColor.new("New Yeller")
  104. game:GetService("Debris"):AddItem(bullet,7.5)
  105. bullet:ApplyImpulse(bullet.CFrame.lookVector * 200)
  106. end
  107. bullet.Touched:Connect(function(partlol)
  108. local partParent3 = partlol.Parent
  109. local humanoid = partParent3:FindFirstChildWhichIsA("Humanoid")
  110. if humanoid ~= owner.Character.Humanoid and humanoid then
  111. if not debounce then
  112. debounce = true
  113. if explodemode then
  114. customExplosion(bullet.Position,15,100)
  115. wait()
  116. bullet:Destroy()
  117. debounce = false
  118. elseif not explodemode then
  119. humanoid.Health = humanoid.Health - 35
  120. wait()
  121. bullet:Destroy()
  122. debounce = false
  123. end
  124. end
  125. end
  126. end)
  127. end
  128. end)
  129. Brickweld2 = Instance.new("NoCollisionConstraint",Brick2)
  130. Brickweld2.Part0 = Brick
  131. Brickweld2.Part1 = Brick2
  132. Brickweld = Instance.new("Weld",Brick2)
  133. Brickweld.Part0 = Brick3
  134. Brickweld.Part1 = Brick2
  135. Brickweld.C0 = CFrame.new(0,-1,0.375)
  136. local attachment0 = Instance.new("Attachment")
  137. attachment0.Parent = Brick2
  138. local attachment1 = Instance.new("Attachment")
  139. attachment1.Parent = owner.Character.Head
  140. alignposition = Instance.new("HingeConstraint")
  141. alignposition.Parent = owner.Character.Head
  142. alignposition.Attachment0 = attachment0
  143. alignposition.Attachment1 = attachment1
  144. attachment1.WorldCFrame = attachment1.Parent.CFrame * CFrame.new(0,0.75,0) * CFrame.Angles(0,0,math.rad(90))
  145. attachment0.WorldCFrame = attachment0.Parent.CFrame * CFrame.Angles(0,0,math.rad(90))
  146. NLS([[
  147. gun = owner.Character:WaitForChild("the thing you shoot")
  148. local mouse = owner:GetMouse()
  149. Brick = owner.Character:WaitForChild("Block")
  150. Brick2 = owner.Character:WaitForChild("Block2")
  151. Brick3 = owner.Character:WaitForChild("Block3")
  152. local bg = Instance.new("BodyGyro",Brick)
  153. bg.D = 100
  154. bg.P = 100000
  155. bg.MaxTorque = Vector3.new(1000000,1000000,1000000)
  156. game:GetService("RunService").RenderStepped:Connect(function()
  157. TweenService = game:GetService("TweenService")
  158. spininfo = TweenInfo.new(0.125,Enum.EasingStyle.Linear)
  159. spininfo2 = TweenInfo.new(0.125,Enum.EasingStyle.Linear)
  160. Spin1 = TweenService:Create(Brick2,spininfo,{CFrame = CFrame.new(Brick2.Position,Vector3.new(mouse.Hit.p.x,Brick2.Position.y,mouse.Hit.p.z))})
  161. Brick.Position = Brick3.Position
  162. Spin2 = TweenService:Create(bg,spininfo2,{CFrame = CFrame.new(Brick3.Position,Vector3.new(mouse.Hit.p.x,mouse.Hit.p.y,mouse.Hit.p.z))})
  163. Spin1:Play()
  164. Spin2:Play()
  165. end)
  166. MouseHold = false
  167. count = 0
  168. mouse.KeyDown:Connect(function(key)
  169. key = key:lower()
  170. if key == "e" then
  171. count = count + 1
  172. if count == 1 then
  173. gun:FireServer("explodemode")
  174. elseif count == 2 then
  175. gun:FireServer("Normal")
  176. task.wait()
  177. count = 0
  178. end
  179. end
  180. end)
  181. mouse.Button1Down:Connect(function()
  182. gun:FireServer("shoot")
  183. MouseHold = true
  184. end)
  185. mouse.Button1Up:Connect(function()
  186. MouseHold = false
  187. end)
  188. while true do
  189. wait(0.125)
  190. if MouseHold then
  191. gun:FireServer("shoot")
  192. end
  193. end
  194. ]], owner.Character)
RAW Paste Data