Advertisement
Modii

Need help with script!

Feb 26th, 2017
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.41 KB | None | 0 0
  1. --can someone DM what I did wrong for this script please?
  2. local Tool = script.Parent;
  3.  
  4. autolength = 5
  5. enabled = true
  6. enabled2 = true
  7. benabled = true
  8. pgui = nil
  9. mtarg = nil
  10. mousedown = false
  11. target = nil
  12. cart = true
  13. electrictextures = {"http://www.roblox.com/asset/?id=109201383", "http://www.roblox.com/asset/?id=109201366", "http://www.roblox.com/asset/?id=109201474", "http://www.roblox.com/asset/?id=109201980", "http://www.roblox.com/asset/?id=109202011"}
  14.  
  15. function BarbTouched(hit, barb)
  16. if hit == nil then return end
  17. if hit.Parent == nil then return end
  18. if hit.Parent:findFirstChild("Humanoid") or hit.Parent:findFirstChild("Zombie") ~= nil then
  19. if hit.Parent.Name == game.Players.LocalPlayer.Name then return end
  20. if target ~= nil then return end
  21.  
  22. if hit.Parent:findFirstChild("OverrideScript") == nil then
  23. local s = script.Parent.OverrideScript:clone()
  24. s.Parent = hit.Parent
  25. target = hit.Parent
  26. s.Disabled = false
  27.  
  28. if hit.Parent:findFirstChild("Humanoid") ~= nil then
  29. Tool.LineV.Value = true
  30. Line = Instance.new("SelectionPartLasso")
  31. print("line")
  32. Line.Name = "strings"
  33. Line.Color = BrickColor.new("Black")
  34. Line.Humanoid = hit.Parent:findFirstChild("Humanoid")
  35. Line.Part = Tool.Electric
  36. Line.Parent = target
  37. end
  38. elseif hit.Parent:findFirstChild("Zombie") ~= nil then
  39. Tool.LineV.Value = true
  40.  
  41. Linez = Instance.new("SelectionPartLasso")
  42. Linez.Name = "strings"
  43. Linez.Color = BrickColor.new("Black")
  44. Linez.Humanoid = hit.Parent:findFirstChild("Zombie")
  45. Linez.Part = Tool.Electric
  46. Linez.Parent = target
  47.  
  48. end
  49.  
  50. barb:Remove()
  51.  
  52. elseif hit.CanCollide == true then
  53. barb:Remove()
  54. end
  55. end
  56.  
  57. function DriveStun(hit)
  58. if hit.Parent:findFirstChild("Humanoid") or hit.Parent:findFirstChild("Zombie") ~= nil then
  59. local s = script.Parent.DriveStunScript:clone()
  60. s.Parent = hit.Parent
  61. s.Disabled = false
  62. end
  63. end
  64.  
  65. function GetElectricTexture()
  66. local r = math.random(1,#electrictextures)
  67. return electrictextures[r]
  68. end
  69.  
  70. function onButton1Down(mouse)
  71. mousedown = true
  72. if not enabled then
  73. return
  74. end
  75. if not enabled2 then return end
  76. enabled = false
  77. enabled2 = false
  78.  
  79. if mouse.Hit ~= nil then
  80. mtarg = mouse.Hit.p
  81. end
  82.  
  83. if cart and benabled then
  84. benabled = false
  85. Tool.Deployed.Value = true
  86. local v = (mtarg - Tool.Cart.Position).unit
  87. local v2 = ((mtarg + Vector3.new(0,-1.5,0)) - Tool.Cart.Position).unit
  88.  
  89. local spawnPos = script.Parent.Cart.Position
  90. spawnPos = spawnPos + (v * 2)
  91.  
  92. Tool.BlastDoor1.Transparency = 1
  93. Tool.BlastDoor2.Transparency = 1
  94.  
  95. local barb_1 = Instance.new("Part")
  96.  
  97. barb_1.Position = spawnPos
  98. barb_1.FormFactor = 3
  99. barb_1.Size = Vector3.new(1,1,1)
  100. barb_1.Velocity = v * 500--1000
  101. barb_1.BrickColor = BrickColor.new(194)
  102. barb_1.BottomSurface = 0
  103. barb_1.TopSurface = 0
  104. barb_1.Name = "TaserBarb"
  105. barb_1.Elasticity = 0
  106. barb_1.Reflectance = 0.1
  107. barb_1.Friction = 1
  108. Tool.BarbMesh:clone().Parent = barb_1
  109.  
  110.  
  111. local sc = Tool.BarbScript:clone()
  112. sc.Parent = barb_1
  113. sc.Disabled = false
  114.  
  115. local force = Instance.new("BodyForce")
  116. force.force = Vector3.new(0,150,0)
  117. force.Parent = barb_1
  118.  
  119. barb_1.Parent = game.Workspace
  120.  
  121. local barb_2 = barb_1:clone()
  122. barb_2.Position = spawnPos + (v2 * 2) + Vector3.new(0,-0.5,0)
  123. barb_2.Velocity = v2 * 500
  124. barb_2.BodyForce.force = Vector3.new(0,150,0)
  125. barb_2.Parent = game.Workspace
  126.  
  127. barb_1.Touched:connect(function(hit) BarbTouched(hit, barb_1) end)
  128. barb_2.Touched:connect(function(hit) BarbTouched(hit, barb_2) end)
  129. Tool.Handle.Shot:Play()
  130.  
  131. local al = 70 * (autolength / 5) + 2
  132. local t = 0
  133. local timerval = 0
  134.  
  135. coroutine.resume(coroutine.create(function()
  136. while not enabled do
  137. t = t + 0.1
  138. if t < autolength then
  139. Tool.TimerVal.Value = math.ceil(autolength - t)
  140. else
  141. Tool.TimerVal.Value = math.ceil(t)
  142. end
  143. wait(0.1)
  144. end
  145. Tool.TimerVal.Value = 0
  146. end))
  147.  
  148. while (mousedown or t < autolength - 0.2) and not safety and t < 90 do
  149. script.Parent.Handle.sound:Play()
  150. script.Parent.Handle.sound2:Play()
  151. script.Parent.Handle.sound3:Play()
  152. wait(0.06)
  153. end
  154.  
  155. if target ~= nil then
  156. if target:findFirstChild("OverrideScript") ~= nil then target.OverrideScript:Remove() end
  157. end
  158.  
  159. Tool.TimerVal.Value = 0
  160. safety = false
  161. enabled = true
  162. wait(0.2)
  163. enabled2 = true
  164.  
  165. elseif cart and target ~= nil then
  166.  
  167. enabled = false
  168. local st = script.Parent.OverrideScript:clone()
  169. st.Disabled = false
  170. st.Parent = target
  171.  
  172. local al = 70 * (autolength / 5) + 2
  173. local t = 0
  174. local timerval = 0
  175.  
  176. coroutine.resume(coroutine.create(function()
  177. while not enabled do
  178. t = t + 0.1
  179. if t < autolength then
  180. Tool.TimerVal.Value = math.ceil(autolength - t)
  181. else
  182. Tool.TimerVal.Value = math.ceil(t)
  183. end
  184. wait(0.1)
  185. end
  186. Tool.TimerVal.Value = 0
  187. end))
  188.  
  189. while (mousedown or t < autolength - 0.2) and not safety and t < 90 do
  190. script.Parent.Handle.sound:Play()
  191. script.Parent.Handle.sound2:Play()
  192. script.Parent.Handle.sound3:Play()
  193. wait(0.06)
  194. end
  195.  
  196. if target ~= nil then
  197. if target:findFirstChild("OverrideScript") ~= nil then target.OverrideScript:Remove() end
  198. end
  199.  
  200. Tool.TimerVal.Value = 0
  201. safety = false
  202. enabled = true
  203. wait(0.2)
  204. enabled2 = true
  205.  
  206. elseif not cart then
  207.  
  208. enabled = false
  209. local con2 = script.Parent.Cart.Touched:connect(DriveStun)
  210.  
  211. local al = 70 * (autolength / 5) + 2
  212. local t = 0
  213.  
  214. coroutine.resume(coroutine.create(function()
  215. while not enabled do
  216. t = t + 0.1
  217. if t < autolength then
  218. Tool.TimerVal.Value = math.ceil(autolength - t)
  219. else
  220. Tool.TimerVal.Value = math.ceil(t)
  221. end
  222. wait(0.1)
  223. end
  224. Tool.TimerVal.Value = 0
  225. end))
  226.  
  227. while (mousedown or t < autolength - 0.2) and not safety and t < 90 do
  228. Tool.Electric.Decal.Texture = GetElectricTexture()
  229. script.Parent.Handle.sound:Play()
  230. script.Parent.Handle.sound2:Play()
  231. script.Parent.Handle.sound3:Play()
  232. wait(0.06)
  233. end
  234.  
  235. Tool.Electric.Decal.Texture = ""
  236. con2:disconnect()
  237.  
  238. Tool.TimerVal.Value = 0
  239. safety = false
  240. enabled = true
  241. wait(0.2)
  242. enabled2 = true
  243. else
  244. enabled = true
  245. enabled2 = true
  246. end
  247. end
  248.  
  249. function onButton1Up(mouse)
  250. mousedown = false
  251. end
  252.  
  253. function UpdateDisplay()
  254. if pgui == nil then return end
  255. if Tool.TimerVal.Value == 0 then
  256. pgui.Main.Countdown.Text = ""
  257. else
  258. pgui.Main.Countdown.Text = Tool.TimerVal.Value
  259. end
  260. if Tool.Cartr.Value == false then
  261. pgui.Main.CartStatus.BackgroundColor3 = Color3.new(255,255,255)
  262. pgui.Main.CartStatus.BorderColor3 = Color3.new(255,255,255)
  263. pgui.Main.CartStatus.Text = "-"
  264. elseif Tool.Deployed.Value == true then
  265. pgui.Main.CartStatus.BackgroundColor3 = Color3.new(255,255,255)
  266. pgui.Main.CartStatus.BorderColor3 = Color3.new(255,0,0)
  267. pgui.Main.CartStatus.Text = "X"
  268. else
  269. pgui.Main.CartStatus.BackgroundColor3 = Color3.new(255,255,255)
  270. pgui.Main.CartStatus.BorderColor3 = Color3.new(255,255,255)
  271. pgui.Main.CartStatus.Text = "1"
  272. end
  273. end
  274.  
  275. function onKeyDown(key)
  276. if key == "y" and Tool.Lamp.Light.Enabled == true then
  277. Tool.Lamp.Light.Enabled = false
  278. elseif key == "y" then
  279. Tool.Lamp.Light.Enabled = true
  280. end
  281. if key == "r" and not enabled then
  282. safety = true
  283. elseif key == "r" and cart then
  284. cart = false
  285. Tool.Cartr.Value = false
  286. Tool.Cart.Transparency = 1
  287. Tool.Cart.CanCollide = false
  288. Tool.CartPart1.Transparency = 1
  289. Tool.CartPart1.CanCollide = false
  290. Tool.CartPart2.Transparency = 1
  291. Tool.CartPart2.CanCollide = false
  292. Tool.BlastDoor1.Transparency = 1
  293. Tool.BlastDoor1.CanCollide = false
  294. Tool.BlastDoor2.Transparency = 1
  295. Tool.BlastDoor2.CanCollide = false
  296. if Tool.LineV.Value == true then
  297. target:FindFirstChild("strings"):remove()
  298. Tool.LineV.Value = false
  299. end
  300. elseif key == "r" then
  301. Tool.Cartr.Value = true
  302. Tool.Deployed.Value = false
  303. cart = true
  304. benabled = true
  305. target = nil
  306. Tool.Cart.Transparency = 0
  307. Tool.Cart.CanCollide = true
  308. Tool.CartPart1.Transparency = 0
  309. Tool.CartPart1.CanCollide = true
  310. Tool.CartPart2.Transparency = 0
  311. Tool.CartPart2.CanCollide = true
  312. Tool.BlastDoor1.Transparency = 0
  313. Tool.BlastDoor1.CanCollide = true
  314. Tool.BlastDoor2.Transparency = 0
  315. Tool.BlastDoor2.CanCollide = true
  316. if Tool.LineV.Value == true then
  317. target:FindFirstChild("strings"):remove()
  318. Tool.LineV.Value = false
  319. end
  320. end
  321. end
  322.  
  323. function onEquippedLocal(mouse)
  324.  
  325. if mouse == nil then
  326. print("Mouse not found")
  327. return
  328. end
  329.  
  330. local h = Tool.Parent:findFirstChild("Humanoid")
  331.  
  332. if h~=nil and game.Players:findFirstChild(h.Parent.Name)~=nil then
  333. local gui = Tool.Gui:clone()
  334. gui.Parent = game.Players:findFirstChild(h.Parent.Name).PlayerGui
  335. pgui = gui
  336.  
  337. UpdateDisplay()
  338.  
  339. Tool.TimerVal.Changed:connect(UpdateDisplay)
  340. Tool.Cartr.Changed:connect(UpdateDisplay)
  341. Tool.Deployed.Changed:connect(UpdateDisplay)
  342. end
  343.  
  344. mouse.Icon = "http://www.roblox.com/asset/?id=2966012"
  345. mouse.Button1Down:connect(function() onButton1Down(mouse) end)
  346. mouse.Button1Up:connect(function() onButton1Up(mouse)end)
  347. mouse.KeyDown:connect(onKeyDown)
  348. end
  349.  
  350.  
  351. Tool.Equipped:connect(onEquippedLocal)
  352.  
  353. function onUnequippedLocal()
  354. if Tool.LineV.Value == true then
  355. target:FindFirstChild("strings"):remove()
  356. Tool.LineV.Value = false
  357. end
  358.  
  359. if pgui ~= nil then
  360. pgui:Remove()
  361. pgui = nil
  362. end
  363. if target ~= nil then
  364. if target:findFirstChild("OverrideScript") ~= nil then target.OverrideScript:Remove() end
  365. end
  366. end
  367.  
  368. Tool.Unequipped:connect(onUnequippedLocal)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement