Advertisement
iamcba12

Tesla Coil Turret NOT FRIGGIN LOCAL

Sep 8th, 2012
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.40 KB | None | 0 0
  1. -- mediafire
  2. --PL0X write ur friend ID HERE :3
  3. WhitelistGlobal = {"19529692", "friend:19529692",
  4. "1566112", "friend:1566112"}
  5.  
  6. Resources = {
  7. ["Tesla Coil"] = {
  8. StartActivated = true, --false,
  9. Arc = {
  10. New = function()
  11. local Arc = Instance.new("Part", Workspace)
  12. Arc.Name = "Tesla Coil Arc"
  13. Arc.BrickColor = BrickColor.new("Bright blue")
  14. Arc.Reflectance = 0.5
  15. Arc.Transparency = 0.1
  16. Arc.TopSurface = 0
  17. Arc.BottomSurface = 0
  18. Arc.Anchored = true
  19. Arc.CanCollide = false
  20. Arc.FormFactor = "Custom"
  21. return Arc
  22. end,
  23. Destroy = function(Object)
  24. coroutine.wrap(function()
  25. wait(0.1)
  26. local Reflectance = Object.Reflectance
  27. local Transparency = Object.Transparency
  28. for i = 0, 1, 0.1 do
  29. Object.Reflectance = Reflectance * (1 - i)
  30. Object.Transparency = Transparency + ((1 - Transparency) * i)
  31. wait()
  32. end
  33. Object:Remove()
  34. end)()
  35. end,
  36. Step = 10
  37. }
  38. }
  39. }
  40.  
  41. function GetRecursiveChildren(Source, Name, SearchType, Children)
  42. if Source == nil then
  43. Source = game
  44. end
  45. if Name == nil or type(Name) ~= "string" then
  46. Name = ""
  47. end
  48. if Children == nil or type(Children) ~= "table" then
  49. Children = {}
  50. end
  51. for _, Child in pairs(Source:children()) do
  52. pcall(function()
  53. if (function()
  54. if SearchType == nil or SearchType == 1 then
  55. return string.match(Child.Name:lower(), Name:lower())
  56. elseif SearchType == 2 then
  57. return string.match(Child.ClassName:lower(), Name:lower())
  58. elseif SearchType == 3 then
  59. return Child:IsA(Name) or Child:IsA(Name:lower())
  60. elseif SearchType == 4 then
  61. return string.match(Child.Name:lower() .. string.rep(string.char(1), 5) .. Child.ClassName:lower(), Name:lower()) or Child:IsA(Name) or Child:IsA(Name:lower())
  62. end
  63. return false
  64. end)() then
  65. table.insert(Children, Child)
  66. end
  67. GetRecursiveChildren(Child, Name, SearchType, Children)
  68. end)
  69. end
  70. return Children
  71. end
  72.  
  73. function WeldPos(Part0, Part1, x, y, z)
  74. local Weld = Instance.new("Weld", Part1)
  75. Weld.Name = "AutoWeld"
  76. Weld.Part0 = Part0
  77. Weld.Part1 = Weld.Parent
  78. Weld.C0 = CFrame.new(x, y, z)
  79. end
  80.  
  81. function _G.MakeTurret(Format, Position)
  82. local Whitelist = WhitelistGlobal
  83. if Format == "Tesla Coil" then
  84. local Activated = Resources[Format].StartActivated
  85. local TeslaCoil = Instance.new("Model")
  86. TeslaCoil.Name = "Tesla Coil"
  87. local Base = Instance.new("Part", TeslaCoil)
  88. Base.Name = "Base"
  89. Base.BrickColor = BrickColor.new("Really black")
  90. Base.TopSurface = 0
  91. Base.BottomSurface = 0
  92. Base.FormFactor = "Custom"
  93. Base.Size = Vector3.new(5, 1, 5)
  94. local Body = Base:Clone()
  95. Body.Parent = TeslaCoil
  96. Body.Name = "Body"
  97. Body.BrickColor = BrickColor.new("Institutional white")
  98. Body.Size = Vector3.new(3.5, 5, 3.5)
  99. local Mesh = Instance.new("CylinderMesh", Body)
  100. WeldPos(Base, Body, 0, 2.75, 0)
  101. local Button = Body:Clone()
  102. Button.Parent = TeslaCoil
  103. Button.Name = "Button"
  104. Button.BrickColor = BrickColor.new(Activated == true and "Bright green" or "Really red")
  105. Button.Size = Vector3.new(3.6, 1, 3.6)
  106. WeldPos(Body, Button, 0, 0, 0)
  107. local ClickDetector = Instance.new("ClickDetector", Button)
  108. ClickDetector.MaxActivationDistance = 5
  109. ClickDetector.MouseClick:connect(function()
  110. Activated = not Activated
  111. Button.BrickColor = BrickColor.new(Activated == true and "Bright green" or "Really red")
  112. end)
  113. local ButtonCover = Button:Clone()
  114. ButtonCover.Parent = TeslaCoil
  115. ButtonCover.Name = "Button Cover"
  116. ButtonCover.BrickColor = BrickColor.new("Really black")
  117. ButtonCover.Size = Vector3.new(3.7, 0.1, 3.7)
  118. WeldPos(Body, ButtonCover, 0, 0.6, 0)
  119. local ButtonCover = ButtonCover:Clone()
  120. ButtonCover.Parent = TeslaCoil
  121. WeldPos(Body, ButtonCover, 0, -0.6, 0)
  122. local Container = Body:Clone()
  123. Container.Parent = TeslaCoil
  124. Container.Name = "Container"
  125. Container.BrickColor = BrickColor.new("Really red")
  126. Container.Size = Vector3.new(1.5, 4, 1.5)
  127. WeldPos(Base, Container, 1.5, 2.25, 1.5)
  128. local Container = Container:Clone()
  129. Container.Parent = TeslaCoil
  130. WeldPos(Base, Container, -1.5, 2.25, 1.5)
  131. local Container = Container:Clone()
  132. Container.Parent = TeslaCoil
  133. WeldPos(Base, Container, -1.5, 2.25, -1.5)
  134. local Container = Container:Clone()
  135. Container.Parent = TeslaCoil
  136. WeldPos(Base, Container, 1.5, 2.25, -1.5)
  137. local ContainerTop = Base:Clone()
  138. ContainerTop.Parent = TeslaCoil
  139. ContainerTop.Name = "Container Top"
  140. ContainerTop.Size = Vector3.new(1.5, 1.5, 1.5)
  141. ContainerTop.BrickColor = BrickColor.new("Really red")
  142. local Mesh = Instance.new("SpecialMesh", ContainerTop)
  143. Mesh.MeshType = "Sphere"
  144. WeldPos(Base, ContainerTop, 1.5, 4.25, 1.5)
  145. local ContainerTop = ContainerTop:Clone()
  146. ContainerTop.Parent = TeslaCoil
  147. WeldPos(Base, ContainerTop, -1.5, 4.25, 1.5)
  148. local ContainerTop = ContainerTop:Clone()
  149. ContainerTop.Parent = TeslaCoil
  150. WeldPos(Base, ContainerTop, -1.5, 4.25, -1.5)
  151. local ContainerTop = ContainerTop:Clone()
  152. ContainerTop.Parent = TeslaCoil
  153. WeldPos(Base, ContainerTop, 1.5, 4.25, -1.5)
  154. local Pole = Body:Clone()
  155. Pole.Parent = TeslaCoil
  156. Pole.Name = "Pole"
  157. Pole.Size = Vector3.new(1, 6, 1)
  158. WeldPos(Body, Pole, 0, 5.5, 0)
  159. local Coil = Body:Clone()
  160. Coil.Parent = TeslaCoil
  161. Coil.Name = "Coil"
  162. Coil.Size = Vector3.new(7, 0.5, 7)
  163. local Mesh = Instance.new("SpecialMesh", Coil)
  164. Mesh.MeshType = "Sphere"
  165. WeldPos(Pole, Coil, 0, -2.5, 0)
  166. local Coil = Coil:Clone()
  167. Coil.Parent = TeslaCoil
  168. Coil.Size = Vector3.new(6, 0.5, 6)
  169. WeldPos(Pole, Coil, 0, -1.5, 0)
  170. local Coil = Coil:Clone()
  171. Coil.Parent = TeslaCoil
  172. Coil.Size = Vector3.new(5, 0.5, 5)
  173. WeldPos(Pole, Coil, 0, -0.5, 0)
  174. local Coil = Coil:Clone()
  175. Coil.Parent = TeslaCoil
  176. Coil.Size = Vector3.new(4, 0.4, 4)
  177. WeldPos(Pole, Coil, 0, 0.5, 0)
  178. local Coil = Coil:Clone()
  179. Coil.Parent = TeslaCoil
  180. Coil.Size = Vector3.new(3, 0.3, 3)
  181. WeldPos(Pole, Coil, 0, 1.5, 0)
  182. local Coil = Coil:Clone()
  183. Coil.Parent = TeslaCoil
  184. Coil.Size = Vector3.new(2, 0.2, 2)
  185. WeldPos(Pole, Coil, 0, 2.25, 0)
  186. local CoilTop = Coil:Clone()
  187. CoilTop.Parent = TeslaCoil
  188. CoilTop.Size = Vector3.new(2, 2, 2)
  189. WeldPos(Pole, CoilTop, 0, 3.5, 0)
  190. TeslaCoil.Parent = Workspace
  191. TeslaCoil:MoveTo(Position == nil and Vector3.new(math.random(-50, 50), 0, math.random(-50, 50)) or Position)
  192. coroutine.wrap(function()
  193. local OldPos = Pole.CFrame
  194. local NewPos = nil
  195. while TeslaCoil.Parent ~= nil do
  196. if Pole:FindFirstChild("AutoWeld") == nil then
  197. Button.BrickColor = BrickColor.new("Really black")
  198. elseif Activated == true then
  199. for _, Part in pairs(GetRecursiveChildren(Workspace, "BasePart", 3)) do
  200. if (function()
  201. if Part.Parent == nil then
  202. return false
  203. end
  204. if Part:IsDescendantOf(TeslaCoil) or Part.Parent.Name == "Tesla Coil" or Part.Name == "Tesla Coil Arc" then
  205. return false
  206. end
  207. for _, PlayerList in pairs(game:GetService("Players"):GetPlayers()) do
  208. if PlayerList.Character ~= nil then
  209. if Part:IsDescendantOf(PlayerList.Character) then
  210. for i = 1, #Whitelist do
  211. if PlayerList.userId == tonumber(Whitelist[i]) then
  212. return false
  213. elseif Whitelist[i]:sub(0, 7) == "friend:" then
  214. if PlayerList:IsFriendsWith(tonumber(Whitelist[i]:sub(8))) then
  215. return false
  216. end
  217. elseif Whitelist[i]:sub(0, 11) == "bestfriend:" then
  218. if PlayerList:IsBestFriendsWith(tonumber(Whitelist[i]:sub(12))) then
  219. return false
  220. end
  221. elseif Whitelist[i]:sub(0, 6) == "group:" then
  222. if PlayerList:IsInGroup(tonumber(Whitelist[i]:sub(7))) then
  223. return false
  224. end
  225. end
  226. end
  227. end
  228. end
  229. end
  230. return true
  231. end)() then
  232. local DestPos = Part.CFrame * CFrame.new(math.random(-Part.Size.x * 1000, Part.Size.x * 1000) / 2000, math.random(-Part.Size.y * 1000, Part.Size.y * 1000) / 2000, math.random(-Part.Size.z * 1000, Part.Size.z * 1000) / 2000)
  233. if (Pole.Position - DestPos.p).magnitude < 50 and math.random(1, 50) == 1 then
  234. local OldPosTemp = OldPos
  235. local OldPos2 = nil
  236. local NewPos2 = nil
  237. for i = (Pole.Position - DestPos.p).magnitude, 0, -Resources[Format].Arc.Step do
  238. if i <= Resources[Format].Arc.Step then i = 0 end
  239. if OldPos2 == nil then
  240. OldPos2 = OldPosTemp
  241. else
  242. OldPos2 = NewPos2
  243. end
  244. NewPos2 = CFrame.new(DestPos.p) * CFrame.new((OldPosTemp.p - DestPos.p).unit * i)
  245. if i > 0 then
  246. NewPos2 = NewPos2 * CFrame.new(math.random(-250, 250) / 100, math.random(-250, 250) / 100, math.random(-250, 250) / 100)
  247. end
  248. local Arc = Resources[Format].Arc.New()
  249. Arc.Size = Vector3.new(0.3, 0.3, (OldPos2.p - NewPos2.p).magnitude)
  250. Arc.CFrame = CFrame.new(NewPos2.p + ((OldPos2.p - NewPos2.p) / 2), NewPos2.p)
  251. Resources[Format].Arc.Destroy(Arc)
  252. end
  253. if Part.Parent:FindFirstChild("Humanoid") ~= nil then
  254. Part.Parent.Humanoid:TakeDamage(math.random(5, 25))
  255. end
  256. end
  257. end
  258. end
  259. for i = 1, math.random(-1, 2) do
  260. if NewPos == nil then
  261. OldPos = Pole.CFrame
  262. else
  263. OldPos = NewPos
  264. end
  265. NewPos = Pole.CFrame * CFrame.new(math.random(-250, 250) / 100, math.random(-300, 400) / 100, math.random(-250, 250) / 100)
  266. local Arc = Resources[Format].Arc.New()
  267. Arc.Size = Vector3.new(0.2, 0.2, (OldPos.p - NewPos.p).magnitude)
  268. Arc.CFrame = CFrame.new(NewPos.p + ((OldPos.p - NewPos.p) / 2), NewPos.p)
  269. Resources[Format].Arc.Destroy(Arc)
  270. end
  271. if math.random(1, 5) == 1 then
  272. local Sound = Instance.new("Sound", Pole)
  273. Sound.SoundId = "http://www.roblox.com/Asset/?id=2974249"
  274. Sound.Pitch = math.random(50, 200) / 100
  275. Sound.Volume = math.random(100, 250) / 1000
  276. Sound.PlayOnRemove = true
  277. coroutine.wrap(function() wait() Sound:Remove() end)()
  278. end
  279. end
  280. wait(0.05)
  281. end
  282. end)()
  283. return TeslaCoil
  284. end
  285. end
  286.  
  287. _G.MakeTurret("Tesla Coil", Vector3.new(100, 0, 0))
  288. _G.MakeTurret("Tesla Coil", Vector3.new(0, 0, 100))
  289. _G.MakeTurret("Tesla Coil", Vector3.new(-100, 0, 0))
  290. _G.MakeTurret("Tesla Coil", Vector3.new(0, 0, -100))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement