StrawberryMemester

Roblox Laser Gun Script

Feb 28th, 2017
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.76 KB | None | 0 0
  1. g = game.Players.LocalPlayer.Name
  2. j = game.Players[g].Character
  3. acc = 2
  4. modes = {"Automatic", "Sniper", "ShotGun", "Burst", "Flame", "Electric"}
  5. modnum = 1
  6. mode = modes[modnum]
  7. local la, ra = j.Torso:findFirstChild("Left Shoulder"),j.Torso:findFirstChild("Right Shoulder")
  8. function weld(par, p1, p2, c1, c2)
  9. local w = Instance.new("Weld")
  10. w.Parent = par
  11. w.Part0 = p1
  12. w.Part1 = p2
  13. pcall(function()
  14. w.C0 = c1
  15. w.C1 = c2
  16. end)
  17. return w
  18. end
  19. mod = Instance.new("Model", j)
  20. mod.Name = "Mod"
  21. local lw;
  22. local rw;
  23. local flw;
  24. local frw;
  25. moof = 0
  26. fcolor = "Really black"
  27. scolor = "Grey"
  28. dcolor = "Royal blue"
  29. left = j["Left Arm"]
  30. pcall(function()
  31. la.Parent, ra.Parent = nil, nil
  32. end)
  33. fl = Instance.new("Part")
  34. fl.Parent = j
  35. fl.Size = Vector3.new(1, 1, 1)
  36. fl.CanCollide = false
  37. fl.Transparency = 1
  38. fl:BreakJoints()
  39. flw = weld(j.Torso, j.Torso, fl, CFrame.new(-1.1, .5, 0.15))
  40. local lw = weld(j.Torso,fl,j["Left Arm"], CFrame.new(0, 0, 0)*CFrame.Angles(math.rad(90), 0,
  41. math.rad(10)))
  42. fr = Instance.new("Part")
  43. fr.Parent = j
  44. fr.Size = Vector3.new(1, 1, 1)
  45. fr.CanCollide = false
  46. fr.Transparency = 1
  47. fr:BreakJoints()
  48. frw = weld(j.Torso, j.Torso, fr, CFrame.new(.2, .5, -1))
  49. local rw = weld(j.Torso,fr,j["Right Arm"], CFrame.new(0, 0, 0)*CFrame.Angles(math.rad(90), 0,
  50. math.rad(-35)))
  51. function cyl(p)
  52. local c = Instance.new("CylinderMesh", p)
  53. return c
  54. end
  55. function sph(p)
  56. local c = Instance.new("SpecialMesh", p)
  57. c.MeshType = "Sphere"
  58. return c
  59. end
  60. function block(p)
  61. local c = Instance.new("BlockMesh", p)
  62. return c
  63. end
  64. local base = Instance.new("Part")
  65. base.Parent = mod
  66. base.Size = Vector3.new(1, 1, 1)
  67. base:BreakJoints()
  68. base.BrickColor = BrickColor.new(fcolor)
  69. local c = block(base)
  70. c.Scale = Vector3.new(.35, 3, .6)
  71. weld(base, base, left, CFrame.new(-.4, 2, .5)*CFrame.Angles(math.rad(0), math.rad(0),
  72. math.rad(10)))
  73. local a = Instance.new("Part")
  74. a.Parent = mod
  75. a.Size = Vector3.new(1, 1, 1)
  76. a:BreakJoints()
  77. a.BrickColor = BrickColor.new(scolor)
  78. local c = block(a)
  79. c.Scale = Vector3.new(.2, .2, .8)
  80. handle = weld(a, a, base, CFrame.new(0, -.7, -.4)*CFrame.Angles(math.rad(10), math.rad(0), 0))
  81. local a2 = Instance.new("Part")
  82. a2.Parent = mod
  83. a2.Size = Vector3.new(1, 1, 1)
  84. a2:BreakJoints()
  85. a2.BrickColor = BrickColor.new(scolor)
  86. local c = block(a2)
  87. c.Scale = Vector3.new(.1, .3, .9)
  88. a2.Name = "Effect"
  89. weld(a2, a2, a, CFrame.new(0, 0, 0))
  90. local a = Instance.new("Part")
  91. a.Parent = mod
  92. a.Size = Vector3.new(1, 1, 1)
  93. a:BreakJoints()
  94. a.BrickColor = BrickColor.new(scolor)
  95. local c = block(a)
  96. c.Scale = Vector3.new(.2, .2, .8)
  97. handle2 = weld(a, a, base, CFrame.new(0, .25, -.4)*CFrame.Angles(math.rad(10), math.rad(0), 0))
  98. local a2 = Instance.new("Part")
  99. a2.Parent = mod
  100. a2.Size = Vector3.new(1, 1, 1)
  101. a2:BreakJoints()
  102. a2.BrickColor = BrickColor.new(scolor)
  103. local c = block(a2)
  104. c.Scale = Vector3.new(.1, .3, .9)
  105. a2.Name = "Effect"
  106. weld(a2, a2, a, CFrame.new(0, 0, 0))
  107. local s = Instance.new("Part")
  108. s.Parent = mod
  109. s.Size = Vector3.new(1, 1, 1)
  110. s:BreakJoints()
  111. s.BrickColor = BrickColor.new(fcolor)
  112. local c = cyl(s)
  113. c.Scale = Vector3.new(.2, 1.4, .2)
  114. weld(s, s, base, CFrame.new(0, 1.5, 0.2)*CFrame.Angles(0, 0, 0))
  115. local s2 = Instance.new("Part")
  116. s2.Parent = mod
  117. s2.Size = Vector3.new(1, 1, 1)
  118. s2:BreakJoints()
  119. s2.BrickColor = BrickColor.new(scolor)
  120. local c = cyl(s2)
  121. c.Scale = Vector3.new(.3, 1.2, .3)
  122. weld(s2, s2, base, CFrame.new(0, 1.5, 0.2)*CFrame.Angles(0, 0, 0))
  123. local s22 = Instance.new("Part")
  124. s22.Parent = mod
  125. s22.Size = Vector3.new(1, 1, 1)
  126. s22.BrickColor = BrickColor.new(dcolor)
  127. local c = cyl(s22)
  128. c.Scale = Vector3.new(.15, .95, .15)
  129. s22:BreakJoints()
  130. weld(s, s22, s, CFrame.new(0, -.1, .1)*CFrame.Angles(0, 0, 0))
  131. s22.Name = "Effect"
  132. local st = Instance.new("Part")
  133. st.Parent = mod
  134. st.Size = Vector3.new(1, 1, 1)
  135. st.BrickColor = BrickColor.new(dcolor)
  136. st:BreakJoints()
  137. weld(st, st, s2, CFrame.new(0, .5, 0)*CFrame.Angles(0, 0, 0))
  138. st.Name = "Tip"
  139. st.Transparency = 1
  140. local st2 = Instance.new("Part")
  141. st2.Parent = mod
  142. st2.Size = Vector3.new(1, 1, 1)
  143. st2.BrickColor = BrickColor.new(dcolor)
  144. st2:BreakJoints()
  145. st2.Name = "Tipl"
  146. st2.Transparency = 1
  147. weld(st2, st2, s, CFrame.new(0, .5, -.3)*CFrame.Angles(0, 0, 0))
  148. local s = Instance.new("Part")
  149. s.Parent = mod
  150. s.Size = Vector3.new(1, 1, 1)
  151. s:BreakJoints()
  152. s.BrickColor = BrickColor.new(fcolor)
  153. local c = cyl(s)
  154. c.Scale = Vector3.new(.2, 1, .2)
  155. weld(s, s, base, CFrame.new(0, 1.5, -0.1)*CFrame.Angles(0, 0, 0))
  156. local s2 = Instance.new("Part")
  157. s2.Parent = mod
  158. s2.Size = Vector3.new(1, 1, 1)
  159. s2:BreakJoints()
  160. s2.BrickColor = BrickColor.new(scolor)
  161. local c = cyl(s2)
  162. c.Scale = Vector3.new(.3, .8, .3)
  163. weld(s2, s2, base, CFrame.new(0, 1.5, -0.1)*CFrame.Angles(0, 0, 0))
  164. for i=1,6 do
  165. local s = Instance.new("Part")
  166. s.Parent = mod
  167. s.Size = Vector3.new(1, 1, 1)
  168. s.BrickColor = BrickColor.new(scolor)
  169. local c = block(s)
  170. c.Scale = Vector3.new(.45, .2, .7)
  171. s:BreakJoints()
  172. weld(s, s, base, CFrame.new(0, -1 + (i*.4), 0.1)*CFrame.Angles(0, 0, 0))
  173. local s2 = Instance.new("Part")
  174. s2.Parent = mod
  175. s2.Size = Vector3.new(1, 1, 1)
  176. s2.BrickColor = BrickColor.new(dcolor)
  177. local c = block(s2)
  178. c.Scale = Vector3.new(.5, .1, .75)
  179. s2:BreakJoints()
  180. weld(s, s2, s, CFrame.new(0, 0, 0)*CFrame.Angles(0, 0, 0))
  181. s2.Name = "Effect"
  182. end
  183. local l = Instance.new("Part")
  184. l.Parent = mod
  185. l.Size = Vector3.new(1, 1, 1)
  186. l:BreakJoints()
  187. l.BrickColor = BrickColor.new(scolor)
  188. l.CanCollide = false
  189. l.formFactor = 0
  190. l.BrickColor = BrickColor.new("Really red")
  191. l.Transparency = .3
  192. local c = cyl(l)
  193. c.Scale = Vector3.new(.3, .8, .3)
  194. c.Name = "c"
  195. l.Name = "Laser"
  196. local w = weld(l, l, st2, CFrame.new(0, 0, 0)*CFrame.Angles(0, 0, 0))
  197. w.Name = "w"
  198. w.Parent = l
  199. for i, v in pairs(mod:GetChildren()) do
  200. v.CanCollide = false
  201. if v.Name == "Effect" then
  202. coroutine.resume(coroutine.create(function()
  203. while true do
  204. for i=1, 25 do
  205. wait()
  206. v.Reflectance = i*4/100
  207. v.Transparency = i*4/100
  208. end
  209. wait()
  210. for i=1,25 do
  211. v.Transparency = i*4/100
  212. v.Reflectance = i*4/100
  213. wait()
  214. end
  215. end
  216. end))
  217. end
  218. end
  219. function ChangeColor(color)
  220. for i, v in pairs(mod:GetChildren()) do
  221. if v.Name == "Effect" then
  222. v.BrickColor = BrickColor.new(color)
  223. end
  224. end
  225. end
  226. if script.Parent.className ~= "HopperBin" then
  227. h = Instance.new("HopperBin")
  228. h.Parent = game.Players[g].Backpack
  229. script.Parent = h
  230. end
  231. rsel = false
  232. las = mod.Laser
  233. lasw = las.w
  234. function snipe(pos, m)
  235. local l = Instance.new("Part")
  236. l.Parent = j
  237. l.BrickColor = BrickColor.new("Dark green")
  238. l.Anchored = true
  239. l.Size = Vector3.new(1, 1, 1)
  240. l.formFactor = 0
  241. local c = Instance.new("CylinderMesh")
  242. c.Parent = l
  243. local rand = Vector3.new(math.random(-.1, .1), math.random(-.1, .1), math.random(-.1, .1))
  244. local looky = (mod.Tip.CFrame-mod.Tip.CFrame.p)*Vector3.new(0, -999, 0)
  245. local a, b = Workspace:FindPartOnRay(Ray.new(mod.Tip.Position+rand, (looky), 999), j)
  246. if a then
  247. a:BreakJoints()
  248. local rot = (a.Position-mod.Tip.Position).magnitude/acc
  249. a.RotVelocity = Vector3.new(math.random(-rot, rot), math.random(-rot, rot), math.random(-rot,
  250. rot))
  251. if a.Name == "Torso" or a.Name == "Head" then --For perfect shot...
  252. l.CFrame = CFrame.new((a.Position+mod.Tip.Position)/2, mod.Tip.Position)*CFrame.Angles(math.pi/2, 0, 0)
  253. c.Scale = Vector3.new(.1, (a.Position-mod.Tip.Position).magnitude, 0.1)
  254. Instance.new("Fire").Parent = a
  255. else
  256. c.Scale = Vector3.new(.1, (b-mod.Tip.Position).magnitude, 0.1)
  257. l.CFrame = CFrame.new((b+mod.Tip.Position+rand)/2,
  258. mod.Tip.Position)*CFrame.Angles(math.pi/2, 0, 0)
  259. local chance = math.random(1, 20)
  260. if chance == 5 then
  261. for i=1,10 do
  262. local e = Instance.new("Explosion", Workspace)
  263. e.BlastRadius = 30
  264. e.BlastPressure = 8000
  265. e.Position = b+Vector3.new(math.random(-4, 4), math.random(-4, 4), math.random(-4, 4))
  266. e.Hit:connect(function(z)
  267. Instance.new("Fire").Parent = z
  268. if z.Name ~= "Base" then
  269. z.Anchored = false
  270. end
  271. z:BreakJoints()
  272. end)
  273. end
  274. end
  275. end
  276. else
  277. c.Scale = Vector3.new(.1, (looky-mod.Tip.Position).magnitude, 0.1)
  278. l.CFrame = CFrame.new((looky+mod.Tip.Position+rand)/2, mod.Tip.Position)*CFrame.Angles(math.pi/2,
  279. 0, 0)
  280. end
  281. coroutine.resume(coroutine.create(function()
  282. for i=0,1,.075 do
  283. l.Transparency = i
  284. wait()
  285. end
  286. l:Remove()
  287. end))
  288. end
  289. function scatter(pos, m)
  290. for i=1,10 do
  291. local l = Instance.new("Part")
  292. l.Parent = j
  293. l.BrickColor = BrickColor.new("Bright yellow")
  294. l.Anchored = true
  295. l.Size = Vector3.new(1, 1, 1)
  296. l.formFactor = 0
  297. local c = Instance.new("CylinderMesh")
  298. c.Parent = l
  299. local tempacc = acc*3.2
  300. local rand = Vector3.new(math.random(-tempacc, tempacc), math.random(-tempacc, tempacc),
  301. math.random(-tempacc, tempacc))
  302. local looky = (mod.Tip.CFrame-mod.Tip.CFrame.p)*Vector3.new(0, -999, 0)
  303. local a, b = Workspace:FindPartOnRay(Ray.new(mod.Tip.Position+rand, (looky), 999), j)
  304. if a then
  305. a:BreakJoints()
  306. if a.Name ~= "Base" then
  307. a.Anchored = false
  308. if a.Name == "Torso" or a.Name == "Head" or a.Parent:findFirstChild("Humanoid") ~= nil then
  309. l.CFrame = CFrame.new((a.Position+mod.Tip.Position)/2, mod.Tip.Position)*CFrame.Angles(math.pi/2,
  310. 0, 0)
  311. c.Scale = Vector3.new(.1, (a.Position-mod.Tip.Position).magnitude, 0.1)
  312. Instance.new("Fire").Parent = a
  313. local bf = Instance.new("BodyForce")
  314. bf.Parent = a
  315. bf.force = (a.Position - mod.Tip.Position).unit*math.random(2300, 4300)
  316. else
  317. c.Scale = Vector3.new(.1, (b-mod.Tip.Position).magnitude, 0.1)
  318. l.CFrame = CFrame.new((b+mod.Tip.Position+rand)/2,
  319. mod.Tip.Position)*CFrame.Angles(math.pi/2, 0, 0)
  320. --[[a.RotVelocity = Vector3.new(math.random(-300, 300), math.random(-300, 300), math.random(-300,
  321. 300))]]
  322. end
  323. end
  324. else
  325. c.Scale = Vector3.new(.1, (looky-mod.Tip.Position).magnitude, 0.1)
  326. l.CFrame = CFrame.new((looky+mod.Tip.Position+rand)/2, mod.Tip.Position)*CFrame.Angles(math.pi/2,
  327. 0, 0)
  328. end
  329. coroutine.resume(coroutine.create(function()
  330. for i=0,1,.075 do
  331. l.Transparency = i
  332. wait()
  333. end
  334. l:Remove()
  335. end))
  336. end
  337. end
  338. function burst(pos, m)
  339. local l = Instance.new("Part")
  340. l.Parent = j
  341. l.BrickColor = BrickColor.new("Bright blue")
  342. l.Anchored = true
  343. l.Size = Vector3.new(1, 1, 1)
  344. l.formFactor = 0
  345. local c = Instance.new("CylinderMesh")
  346. c.Parent = l
  347. local tempacc = acc*1.2
  348. local rand = Vector3.new(math.random(-tempacc, tempacc), math.random(-tempacc, tempacc),
  349. math.random(-tempacc, tempacc))
  350. local looky = (mod.Tipl.CFrame-mod.Tipl.CFrame.p)*Vector3.new(0, -999, 0)
  351. local a, b = Workspace:FindPartOnRay(Ray.new(mod.Tip.Position+rand, (looky), 999), j)
  352. if a then
  353. a:BreakJoints()
  354. a.Reflectance = 1
  355. a.Anchored = true
  356. if a.Name == "Torso" or a.Name == "Head" or a.Parent:findFirstChild("Humanoid") ~= nil then
  357. --[[For perfect shot...]]
  358. l.CFrame = CFrame.new((a.Position+mod.Tip.Position)/2, mod.Tip.Position)*CFrame.Angles(math.pi/2,
  359. 0, 0)
  360. c.Scale = Vector3.new(.1, (a.Position-mod.Tip.Position).magnitude, 0.1)
  361. else
  362. c.Scale = Vector3.new(.1, (b-mod.Tip.Position).magnitude, 0.1)
  363. l.CFrame = CFrame.new((b+mod.Tip.Position+rand)/2,
  364. mod.Tip.Position)*CFrame.Angles(math.pi/2, 0, 0)
  365. --[[a.RotVelocity = Vector3.new(math.random(-300, 300), math.random(-300, 300), math.random(-300,
  366. 300))]]
  367. end
  368. else
  369. c.Scale = Vector3.new(.1, (looky-mod.Tip.Position).magnitude, 0.1)
  370. l.CFrame = CFrame.new((looky+mod.Tip.Position+rand)/2, mod.Tip.Position)*CFrame.Angles(math.pi/2,
  371. 0, 0)
  372. end
  373. coroutine.resume(coroutine.create(function()
  374. for i=0,1,.075 do
  375. l.Transparency = i
  376. wait()
  377. end
  378. l:Remove()
  379. end))
  380. end
  381. time = 0.001
  382. function dop(m)
  383. sele = true
  384. while sele == true do
  385. if mode == "Automatic" then
  386. fire(m.Hit.p, m)
  387. shootanim()
  388. ChangeColor("Really red")
  389. time = 0.001
  390. elseif mode == "Sniper" then
  391. snipe(m.Hit.p, m)
  392. shootanim()
  393. ChangeColor("Dark green")
  394. time = 1
  395. elseif mode == "ShotGun" then
  396. scatter(m.Hit.p, m)
  397. shootanim()
  398. ChangeColor("Bright yellow")
  399. time = .4
  400. elseif mode == "Burst" then
  401. ChangeColor("Bright blue")
  402. for i=1,4 do
  403. burst(m.Hit.p, m)
  404. time = .7
  405. shootanim()
  406. wait()
  407. end
  408. elseif mode == "Flame" then
  409. flame(m.Hit.p, m)
  410. ChangeColor("Dark orange")
  411. time = .01
  412. elseif mode == "Electric" then
  413. electic(m.Hit.p, m)
  414. ChangeColor("Institutional white")
  415. time = .1
  416. end
  417. wait(time)
  418. end
  419. end
  420. function shootanim()
  421. for i=1,2 do
  422. flw.C0 = flw.C0*CFrame.new(0, 0, 0.3)
  423. frw.C0 = frw.C0*CFrame.new(0, 0, 0.3)
  424. wait()
  425. end
  426. for i=1,2 do
  427. flw.C0 = flw.C0*CFrame.new(0, 0, -0.3)
  428. frw.C0 = frw.C0*CFrame.new(0, 0, -0.3)
  429. wait()
  430. end
  431. end
  432. function electic(pos, m)
  433. local rand = Vector3.new(math.random(-acc, acc), math.random(-acc, acc), math.random(-acc, acc))
  434. local looky = (mod.Tip.CFrame-mod.Tip.CFrame.p)*Vector3.new(0, -999, 0)
  435. local a, b = Workspace:FindPartOnRay(Ray.new(mod.Tip.Position+rand, (looky), 999), j)
  436. if a then
  437. if a.Name == "Ele" then
  438. return
  439. end
  440. elect(b)
  441. coroutine.resume(coroutine.create(function()
  442. wait((mod.Tip.Position-a.Position).magnitude/100)
  443. local last = a.Position
  444. for i=1,25 do
  445. wait()
  446. if a.Name ~= "Base" then
  447. a:BreakJoints()
  448. a.Anchored = false
  449. end
  450. local siz = a.Size + Vector3.new(3, 3, 3)
  451. local new = a.Position+Vector3.new(math.random(-siz.X/2, siz.X/2), math.random(-siz.Y/2, siz.Y/2), math.random(-siz.Z/2, siz.Z/2))
  452. Eff(last, new)
  453. wait()
  454. last = new
  455. end
  456. end))
  457. else
  458. elect(mod.Tip.Position + ((mod.Tip.CFrame-mod.Tip.CFrame.p)*Vector3.new(0, -20, 0)))
  459. end
  460. end
  461. function unp(m)
  462. sele = false
  463. ChangeColor("Royal blue")
  464. end
  465. function key(k)
  466. if k == "q" then
  467. for i=1, 20 do
  468. p = Instance.new("Part", workspace)
  469. p.CFrame = CFrame.new(0, 10+i, 0)
  470. end
  471. end
  472. if k == "e" then
  473. for i=1, 1 do
  474. p = Instance.new("Part", workspace)
  475. p.CFrame = CFrame.new(0, 0, 0)
  476. p.Anchored = true
  477. p.Size = Vector3.new(5, 5, 5)
  478. end
  479. end
  480. if k == "z" then
  481. if modnum > 1 then
  482. modnum = modnum - 1
  483. mode = modes[modnum]
  484. end
  485. end
  486. if k == "x" then
  487. if modnum < #modes then
  488. modnum = modnum + 1
  489. mode = modes[modnum]
  490. end
  491. end
  492. end
  493. function fire(pos, m)
  494. local l = Instance.new("Part")
  495. l.Parent = j
  496. l.BrickColor = BrickColor.new("Really red")
  497. l.Anchored = true
  498. l.Size = Vector3.new(1, 1, 1)
  499. l.formFactor = 0
  500. local c = Instance.new("CylinderMesh")
  501. c.Parent = l
  502. local rand = Vector3.new(math.random(-acc, acc), math.random(-acc, acc), math.random(-acc, acc))
  503. local looky = (mod.Tip.CFrame-mod.Tip.CFrame.p)*Vector3.new(0, -999, 0)
  504. local a, b = Workspace:FindPartOnRay(Ray.new(mod.Tip.Position+rand, (looky), 999), j)
  505. if a then
  506. a:BreakJoints()
  507. if a.Name ~= "Base" then
  508. a.Anchored = false
  509. end
  510. if a.Name == "Torso" or a.Name == "Head" then --For perfect shot...
  511. l.CFrame = CFrame.new((a.Position+mod.Tip.Position)/2, mod.Tip.Position)*CFrame.Angles(math.pi/2,
  512. 0, 0)
  513. c.Scale = Vector3.new(.1, (a.Position-mod.Tip.Position).magnitude, 0.1)
  514. else
  515. c.Scale = Vector3.new(.1, (b-mod.Tip.Position).magnitude, 0.1)
  516. l.CFrame = CFrame.new((b+mod.Tip.Position+rand)/2,
  517. mod.Tip.Position)*CFrame.Angles(math.pi/2, 0, 0)
  518. end
  519. else
  520. c.Scale = Vector3.new(.1, (looky-mod.Tip.Position).magnitude, 0.1)
  521. l.CFrame = CFrame.new((looky+mod.Tip.Position+rand)/2, mod.Tip.Position)*CFrame.Angles(math.pi/2,
  522. 0, 0)
  523. end
  524. coroutine.resume(coroutine.create(function()
  525. for i=0,1,.075 do
  526. l.Transparency = i
  527. wait()
  528. end
  529. l:Remove()
  530. end))
  531. end
  532. Colors = {"Dark orange", "Bright yellow", "Really red", "Really black"}
  533. function flame(pos, m)
  534. local l = Instance.new("Part")
  535. l.Parent = j
  536. l.BrickColor = BrickColor.new(Colors[math.random(1, #Colors)])
  537. l.Anchored = true
  538. l.Size = Vector3.new(1, 1, 1)
  539. block(l)
  540. local f = Instance.new("Fire", l)
  541. f.Color = Color3.new(0, 0, 1)
  542. local st = (mod.Tip.CFrame-mod.Tip.CFrame.p)*Vector3.new(math.random(-1, 1), -2, math.random(-1, 1))
  543. l.CFrame = (mod.Tip.CFrame + Vector3.new(CFrame.new(st)))
  544. --[[*CFrame.Angles(math.rad(math.random(-20, 20)), math.rad(math.random(-20, 20)), math.rad(math.random(-20, 20))) ))]]
  545. l.CFrame = l.CFrame*CFrame.Angles(math.rad(math.random(-180, 180)), math.rad(math.random(-180, 180)), math.rad(math.random(-180, 180)))
  546. coroutine.resume(coroutine.create(function()
  547. for i=1,math.random(6, 9) do
  548. wait()
  549. l.CFrame = l.CFrame+Vector3.new(st.X, st.Y/4, st.Z)
  550. l.CFrame = l.CFrame + Vector3.new(0, i*0.2, 0)
  551. l.CFrame = l.CFrame*CFrame.Angles(math.rad(i), math.rad(i), math.rad(i))
  552. l.Transparency = l.Transparency + 0.1
  553. local a, b = Workspace:FindPartOnRay(Ray.new(l.Position, l.CFrame.lookVector*5, 994), j)
  554. if a then
  555. if a.Name ~= "Base" then
  556. local p = Instance.new("Part")
  557. p.Parent = a
  558. p.CanCollide = false
  559. p:BreakJoints()
  560. p.Transparency = 1
  561. p.Size = Vector3.new(1, 1, 1)
  562. p.CFrame = CFrame.new(b.X, b.Y, b.Z)
  563. p.Anchored = true
  564. local f = Instance.new("Fire", p)
  565. Instance.new("Fire").Parent = a
  566. f.Color = Color3.new(0, 0, 1)
  567. a.BrickColor = BrickColor.new("Really black")
  568. a.Anchored = false
  569. a:BreakJoints()
  570. l:Remove()
  571. --weld(p, p, a, CFrame.new(b.X, b.Y, b.Z))
  572. break
  573. end
  574. end
  575. end
  576. pcall(function()
  577. l:Remove()
  578. end)
  579. end))
  580. end
  581. coroutine.resume(coroutine.create(function()
  582. while true do
  583. wait()
  584. local looky = (mod.Tipl.CFrame-mod.Tipl.CFrame.p)*Vector3.new(0, -999, 0)
  585. local a, b = Workspace:FindPartOnRay(Ray.new(mod.Tipl.Position, (looky), 999), j)
  586. if a then
  587. if a.Name ~= "Ele" then
  588. las.c.Scale = Vector3.new(.1,(mod.Tipl.Position-b).magnitude, .1)
  589. las.c.Offset = Vector3.new(0, -(b - mod.Tipl.Position).magnitude/2, 0)
  590. --lasw.C0 = CFrame.new(0, (b - mod.Tipl.Position).magnitude/2, 0)
  591. lasw.C0 = CFrame.new(0, 0, 0)
  592. end
  593. else
  594. las.c.Scale = Vector3.new(.1, 1000, .1)
  595. --lasw.C0 = CFrame.new(0, 500, 0)
  596. lasw.C0 = CFrame.new(0, 0, 0)
  597. las.c.Offset = Vector3.new(0, -500, 0)
  598. end
  599. end
  600. end))
  601. function Eff(last, rand)
  602. local p = Instance.new("Part")
  603. p.Parent = Workspace
  604. p.Name = "Ele"
  605. p.Size = Vector3.new(1, 1, 1)
  606. p.Anchored = true
  607. p.formFactor = 0
  608. p.BrickColor = BrickColor.new("Bright yellow")
  609. p.CanCollide = false
  610. local c = Instance.new("CylinderMesh")
  611. c.Parent = p
  612. c.Scale = Vector3.new(.1, (last-rand).magnitude, .1)
  613. p.CFrame = CFrame.new((last+rand)/2, last)*CFrame.Angles(math.pi/2, 0, 0)
  614. coroutine.resume(coroutine.create(function()
  615. for i=0, 1, .075 do
  616. p.Transparency = i
  617. wait()
  618. end
  619. p:Remove()
  620. end))
  621. end
  622. function elect(pos)
  623. local targ = pos
  624. part = mod.Tip
  625. local change = 2
  626. local last = part.Position
  627. coroutine.resume(coroutine.create(function()
  628. while true do
  629. local fast = math.random(1, 4)
  630. if fast == 3 then
  631. wait()
  632. end
  633. local un = (targ-last).unit
  634. if (last-targ).magnitude < 10 then
  635. new = targ
  636. Eff(last, new)
  637. break
  638. else
  639. local new = last+((un*5)+Vector3.new(math.random(-change, change), math.random(-change, change), math.random(-change, change)))
  640. Eff(last, new)
  641. last = new
  642. end
  643. end
  644. end))
  645. end
  646. function sel(m)
  647. rsel = true
  648. coroutine.resume(coroutine.create(function()
  649. while true do
  650. wait()
  651. if m.Target ~= nil then
  652. moof = m.Hit
  653. if rsel == true then
  654. lw.C0 = CFrame.new(0, 0, 0)*CFrame.Angles(math.rad(90+moof.Y), math.rad(0), math.rad(10))
  655. rw.C0 = CFrame.new(0, 0, 0)*CFrame.Angles(math.rad(90+moof.Y), math.rad(0), math.rad(-35))
  656. end
  657. end
  658. end
  659. end))
  660. m.Button1Down:connect(function() dop(m) end)
  661. m.Button1Up:connect(function() unp(m) end)
  662. m.KeyDown:connect(function(k) key(k) end)
  663. end
  664. script.Parent.Selected:connect(sel) --lego
  665. function dsel(m)
  666. rsel = false
  667. end
  668. script.Parent.Deselected:connect(dsel) --lego
Add Comment
Please, Sign In to add comment