PotatoSaiyan

Light Saber Script

Jun 30th, 2016
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.41 KB | None | 0 0
  1. --Saber
  2. local plr = game:service'Players'.LocalPlayer
  3. local char = plr.Character
  4. local mouse = plr:GetMouse()
  5. local torso = char:findFirstChild("Torso")
  6. local head = char.Head
  7. local ra = char:findFirstChild("Right Arm")
  8. local la = char:findFirstChild("Left Arm")
  9. local rl = char:findFirstChild("Right Leg")
  10. local ll = char:findFirstChild("Left Leg")
  11. local rs = torso:findFirstChild("Right Shoulder")
  12. local ls = torso:findFirstChild("Left Shoulder")
  13. local equipped = false
  14. local debounce = false
  15. local slashing = false
  16. local blocking = false
  17. local blocking2 = false
  18. local stoopidstuff = Instance.new("BoolValue", char)
  19. stoopidstuff.Name = "stoopidstuff"
  20. stoopidstuff.Value = true
  21. local healing = false
  22. local storedhealth
  23. local storewalkspeed = char:findFirstChild("Humanoid").WalkSpeed
  24. local damage = 9999991e+9999
  25. local colors = {"Bright red"}
  26. function part(parent, size, formfactor, color, collide, transparency)
  27. local p=Instance.new("Part", parent)
  28. p.FormFactor=formfactor
  29. p.CanCollide=false
  30. p.Size=size
  31. p.Locked=true
  32. p.Transparency=transparency
  33. p.Position=torso.Position
  34. p.BrickColor=color
  35. p.FrontSurface="SmoothNoOutlines"
  36. p.BackSurface="SmoothNoOutlines"
  37. p.LeftSurface="SmoothNoOutlines"
  38. p.BottomSurface="SmoothNoOutlines"
  39. p.TopSurface="SmoothNoOutlines"
  40. p.RightSurface="SmoothNoOutlines"
  41. return p
  42. end
  43. function wedge(parent, size, formfactor, color, collide)
  44. local p=Instance.new("Wedge", parent)
  45. p.FormFactor=formfactor
  46. p.CanCollide=false
  47. p.Size=size
  48. p.Locked=true
  49. p.Position = torso.Position
  50. p.BrickColor=color
  51. p.FrontSurface="SmoothNoOutlines"
  52. p.BackSurface="SmoothNoOutlines"
  53. p.LeftSurface="SmoothNoOutlines"
  54. p.BottomSurface="SmoothNoOutlines"
  55. p.TopSurface="SmoothNoOutlines"
  56. p.RightSurface="SmoothNoOutlines"
  57. return p
  58. end
  59. function weld(c0, c1, part1, part0)
  60. local wel=Instance.new("Weld", char)
  61. wel.Part0 = part0
  62. wel.Part1 = part1
  63. wel.C0 = c0
  64. wel.C1 = c1
  65. return wel
  66. end
  67. function specialmesh(parent, meshType, scale, meshId)
  68. local mesh = Instance.new("SpecialMesh", parent)
  69. mesh.Scale = scale
  70. mesh.MeshType = meshType
  71. mesh.MeshId = meshId
  72. return mesh
  73. end
  74. function equip()
  75. ar = Instance.new("Part", char)
  76. ar.FormFactor = "Custom"
  77. ar.Size = Vector3.new(1, 1, 1)
  78. ar.Transparency = 1
  79. ar.CanCollide = false
  80. ar.Locked = true
  81. ar:BreakJoints()
  82. fakel = Instance.new("Weld", char)
  83. fakel.Part0 = char.Torso
  84. fakel.Part1 = ar
  85. coroutine.wrap(function()
  86. for angle = 0, 45, 5 do
  87. if fakel == nil then return end
  88. fakel.C0 = CFrame.new(1.5, 0.5, 0) * CFrame.Angles(math.rad(angle), math.rad(0), math.rad(0))
  89. wait()
  90. end
  91. end)()
  92. welditbro = Instance.new("Weld", char)
  93. welditbro.C0 = CFrame.new(0, 0.5, 0)
  94. welditbro.Part0 = ra
  95. welditbro.Part1 = ar
  96. end
  97. function block()
  98. if not equipped then return end
  99. stoopidstuff.Value = true
  100. damage = 200000000
  101. char:findFirstChild("Humanoid").WalkSpeed = 6
  102. storedhealth = char:findFirstChild("Humanoid").Health
  103. for angle = 0, 70, 10 do
  104. fakel.C0 = CFrame.new(1.5, 0.5, 0) * CFrame.Angles(math.rad(45), math.rad(angle), 0)
  105. wait()
  106. end
  107. coroutine.wrap(function()
  108. while blocking do
  109. if not blocking then return end
  110. char:findFirstChild("Humanoid").Health = storedhealth
  111. game:service'RunService'.Stepped:wait()
  112. end
  113. end)()
  114. end
  115. function unblock()
  116. stoopidstuff.Value = false
  117. if not equipped then return end
  118. damage = 3000000
  119. char:findFirstChild("Humanoid").WalkSpeed = storewalkspeed
  120. for angle = 70, 0, -10 do
  121. fakel.C0 = CFrame.new(1.5, 0.5, 0) * CFrame.Angles(math.rad(45), math.rad(angle), 0)
  122. wait()
  123. end
  124. blocking = false
  125. end
  126. function block2()
  127. if not equipped then return end
  128. stoopidstuff.Value = true
  129. damage = 20000000
  130. char:findFirstChild("Humanoid").WalkSpeed = 6
  131. storedhealth = char:findFirstChild("Humanoid").Health
  132. for angle = 0, 50, 10 do
  133. fakel.C0 = CFrame.new(1.5, 0.5, 0) * CFrame.Angles(math.rad(45 + angle/6), 0, -math.rad(angle))
  134. wait()
  135. end
  136. coroutine.wrap(function()
  137. while blocking2 do
  138. if not blocking2 then return end
  139. char:findFirstChild("Humanoid").Health = storedhealth
  140. game:service'RunService'.Stepped:wait()
  141. end
  142. end)()
  143. end
  144. function unblock2()
  145. stoopidstuff.Value = false
  146. if not equipped then return end
  147. damage = 30000
  148. char:findFirstChild("Humanoid").WalkSpeed = storewalkspeed
  149. for angle = 50, 0, -10 do
  150. fakel.C0 = CFrame.new(1.5, 0.5, 0) * CFrame.Angles(math.rad(45 + angle/6), math.rad(0), -math.rad(angle))
  151. wait()
  152. end
  153. blocking2 = false
  154. end
  155. function heal()
  156. ar2 = Instance.new("Part", char)
  157. ar2.FormFactor = "Custom"
  158. ar2.Size = Vector3.new(1, 1, 1)
  159. ar2.Transparency = 1
  160. ar2.CanCollide = false
  161. ar2.Locked = true
  162. ar2:BreakJoints()
  163. fakel2 = Instance.new("Weld", char)
  164. fakel2.Part0 = torso
  165. fakel2.Part1 = ar2
  166. welditbro2 = Instance.new("Weld", char)
  167. welditbro2.C0 = CFrame.new(0, 0.5, 0)
  168. welditbro2.Part0 = la
  169. welditbro2.Part1 = ar2
  170. for angle = 0, 170, 5 do
  171. fakel2.C0 = CFrame.new(-1.5, 0.5, 0) * CFrame.Angles(math.rad(angle), math.rad(0), math.rad(0))
  172. wait()
  173. end
  174. local ball = Instance.new("Part", char)
  175. ball.FormFactor = "Custom"
  176. ball.BrickColor = BrickColor.new("Lime green")
  177. ball.Anchored = true
  178. ball.CanCollide = false
  179. ball.TopSurface = 0
  180. ball.BottomSurface = 0
  181. ball.Transparency = 0.4
  182. ball.Locked = true
  183. ball.Shape = "Ball"
  184. ball.CFrame = torso.CFrame
  185. local mesh = Instance.new("SpecialMesh", ball)
  186. mesh.MeshType = "Sphere"
  187. coroutine.wrap(function()
  188. for i = 0.2, 8, 0.1 do
  189. mesh.Scale = Vector3.new(i, i, i)
  190. ball.Transparency = ball.Transparency + 0.005
  191. wait()
  192. end
  193. ball:Destroy()
  194. end)()
  195. local splash = Instance.new("Part", char)
  196. splash.FormFactor = "Custom"
  197. splash.BrickColor = BrickColor.new("Lime green")
  198. splash.Transparency = 0
  199. splash.Anchored = true
  200. splash.CanCollide = false
  201. splash.BottomSurface = 0
  202. splash.TopSurface = 0
  203. splash.Locked = true
  204. local mesh = Instance.new("SpecialMesh", splash)
  205. mesh.MeshType = "FileMesh"
  206. mesh.Scale = Vector3.new(1, 1, 1)
  207. mesh.MeshId = "http://www.roblox.com/asset/?id=3270017"
  208. splash:BreakJoints()
  209. splash.CFrame = ball.CFrame * CFrame.Angles(math.rad(90), 0, 0)
  210. coroutine.resume(coroutine.create(function()
  211. for i = 0, 50, 0.5 do
  212. mesh.Scale = Vector3.new(i, i, 1)
  213. splash.Transparency = splash.Transparency + 0.01
  214. wait()
  215. end
  216. splash:Destroy()
  217. end))
  218.  
  219. char:findFirstChild("Humanoid").Health = char:findFirstChild("Humanoid").Health + 1000
  220. wait(0.5)
  221. welditbro2:Destroy()
  222. fakel2:Destroy()
  223. ar2:Destroy()
  224. ls.Parent = torso
  225. wait(1)
  226. healing = false
  227. end
  228.  
  229. function slash()
  230. if blocking then return end
  231. if blocking2 then return end
  232. if not equipped then return end
  233. damage = 200000000
  234. for angle = 45, 95, 10 do
  235. fakel.C0 = CFrame.new(1.5, 0.5, 0) * CFrame.Angles(math.rad(angle), math.rad(angle/2), 0)
  236. wait()
  237. end
  238. for angle = 95, 5, -20 do
  239. fakel.C0 = CFrame.new(1.5, 0.5, 0) * CFrame.Angles(math.rad(angle), math.rad(angle/2), 0)
  240. wait()
  241. end
  242. for angle = 5, 45, 10 do
  243. fakel.C0 = CFrame.new(1.5, 0.5, 0) * CFrame.Angles(math.rad(angle), math.rad(angle/angle - 5), 0)
  244. wait()
  245. end
  246. slashing = false
  247. fakel.C0 = CFrame.new(1.5, 0.5, 0) * CFrame.Angles(math.rad(45), 0, 0)
  248. damage = 200000000
  249. wait(0.2)
  250. end
  251. function deequip()
  252. pcall(function()
  253. ar:Destroy()
  254. fakel:Destroy()
  255. welditbro:Destroy()
  256. end)
  257. end
  258.  
  259. local part1 = part(char, Vector3.new(0.2, 1.4, 0.2), "Custom", BrickColor.new("Black"), 0)
  260. Instance.new("CylinderMesh", part1)
  261. local weld1 = weld(CFrame.new(0, 0, 1) * CFrame.Angles(math.pi/2, 0, 0), CFrame.new(), ra, part1)
  262. local part2 = part(char, Vector3.new(0.4, 0.4, 0.4), "Custom", BrickColor.new("Black"), 0)
  263. Instance.new("CylinderMesh", part2)
  264. local weld3 = weld(CFrame.new(0, 0.65, 0), CFrame.new(), part2, part1)
  265. local part3 = part(char, Vector3.new(0.3, 4.4, 0.3), "Custom", BrickColor.White(), 0)
  266. local mesh1 = specialmesh(part3, "Head", Vector3.new(0.8, 1, 0.8), "")
  267. local weld4 = weld(CFrame.new(0, 2.9, 0), CFrame.new(), part3, part1)
  268. local part4 = part(char, Vector3.new(0.4, 4.4, 0.4), "Custom", BrickColor.new(colors[math.random(1, #colors)]), 0)
  269. local mesh2 = specialmesh(part4, "Head", Vector3.new(1, 1.01, 1), "")
  270. local weld5 = weld(CFrame.new(0, 2.9, 0), CFrame.new(), part4, part1)
  271. local pl = Instance.new("PointLight", part4)
  272. pl.Color = part4.BrickColor.Color
  273. pl.Brightness = 0
  274. part3.Transparency = 1
  275. part4.Transparency = 1
  276. part4.Touched:connect(function(hit)
  277. if not equipped then return end
  278. if debounce then return end
  279. debounce = true
  280. coroutine.wrap(function()
  281. pcall(function()
  282. if hit.Parent:FindFirstChild("Humanoid") ~= nil then
  283. if hit.Parent.Name == char.Name then return end
  284. if hit.Parent:findFirstChild("stoopidstuff") ~= nil and hit.Parent:findFirstChild("stoopidstuff").Value == true then
  285. return
  286. end
  287. damagerandom = damage + math.random(0, 10)
  288. hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - damagerandom
  289. coroutine.wrap(function()
  290. local prt = Instance.new("Part", char)
  291. prt.FormFactor = "Custom"
  292. prt.Size = Vector3.new(0.1, 0.1, 0.1)
  293. prt.Transparency = 1
  294. prt.CanCollide = false
  295. prt.CFrame = CFrame.new(part4.CFrame.x, part4.CFrame.y, part4.CFrame.z)
  296. prt.Anchored = true
  297. coroutine.resume(coroutine.create(function()
  298. for i = 2, 10, 0.05 do
  299. if prt == nil then return end
  300. prt.CFrame = prt.CFrame * CFrame.new(0, 0.05, 0)
  301. game:service'RunService'.Stepped:wait()
  302. end
  303. end))
  304.  
  305. local bg = Instance.new("BillboardGui")
  306. bg.Parent = prt
  307. bg.Adornee = prt
  308. bg.Size = UDim2.new(4, 0, 3.5, 0)
  309. bg.ExtentsOffset = Vector3.new(0, 0, 0)
  310. local lol = Instance.new("TextLabel")
  311. lol.Size = UDim2.new(1.3, 0, 0.4, 0)
  312. lol.TextScaled = true
  313. lol.TextWrapped = true
  314. lol.BackgroundTransparency = 0.4
  315. lol.Parent = bg
  316. lol.FontSize = "Size24"
  317. lol.TextColor3 = Color3.new(1, 0, 0)
  318. lol.TextStrokeTransparency = 0
  319. lol.Font = "ArialBold"
  320. lol.Text = "-"..damagerandom
  321.  
  322. wait(5)
  323. prt:Destroy()
  324. end)()
  325. end
  326. end)
  327. end)()
  328. wait(0.1)
  329. debounce = false
  330. end)
  331. mouse.Button1Down:connect(function(mouse)
  332. if slashing then return end
  333. if not equipped then return end
  334. if blocking2 then return end
  335. if blocking then return end
  336. slashing = true
  337. slash()
  338. end)
  339. mouse.KeyUp:connect(function(key)
  340.  
  341. if key == "f" then
  342. if not equipped then return end
  343. if not blocking then return end
  344. unblock()
  345. char:findFirstChild("Humanoid").MaxHealth = 100
  346. end
  347. if key == "g" then
  348. if not equipped then return end
  349. if not blocking2 then return end
  350. unblock2()
  351. char:findFirstChild("Humanoid").MaxHealth = 100
  352. end
  353. end)
  354. mouse.KeyDown:connect(function(key)
  355. if key == "f" then
  356. if not equipped then return end
  357. if blocking then return end
  358. if blocking2 then return end
  359. blocking = true
  360. block()
  361. end
  362. if key == "g" then
  363. if not equipped then return end
  364. if blocking then return end
  365. if blocking2 then return end
  366. blocking2 = true
  367. block2()
  368. end
  369. if key == "v" then
  370. if healing then return end
  371. if slashing then return end
  372. healing = true
  373. heal()
  374. end
  375. if key == "q" then
  376. if blocking2 then return end
  377. if blocking then return end
  378. equipped = not equipped
  379. if equipped then
  380. coroutine.wrap(function()
  381. while equipped do
  382. part4.Transparency = 0.6
  383. pl.Brightness = 0.6
  384. wait(0.05)
  385. part4.Transparency = 0.7
  386. pl.Brightness = 0.8
  387. wait(0.05)
  388. end
  389. end)()
  390. weld1.Part1 = ra
  391. weld1.C0 = CFrame.new(0, 0, 1) * CFrame.Angles(math.pi/2, 0, 0)
  392. part3.Transparency = 0
  393. local sound = Instance.new("Sound", char.Head)
  394. sound.SoundId = [[rbxasset://sounds\Rocket whoosh 01.wav]]
  395. sound.Pitch = 3
  396. sound.Volume = 1
  397. sound:play()
  398. equip()
  399. wait(1)
  400. sound:stop()
  401. sound:Destroy()
  402. else
  403. deequip()
  404. wait(0.1)
  405. weld1.Part1 = rl
  406. weld1.C0 = CFrame.new(-0.6,-0.8,-0.2) * CFrame.Angles(math.pi/4, 0, 0)
  407. part3.Transparency = 1
  408. pl.Brightness = 0
  409. part4.Transparency = 1
  410. end
  411. end
  412.  
  413. end)
  414. while true do
  415.  
  416. if slashing then
  417. local clone = part4:clone()
  418. clone.Anchored = true
  419. clone.Parent = workspace
  420. clone.Name = "trail"
  421. clone:findFirstChild("Mesh"):Destroy()
  422. Instance.new("BlockMesh", clone)
  423. clone.Mesh.Scale = clone.Mesh.Scale - Vector3.new(0.8, 0, 0) + Vector3.new(0, 0, 1.6)
  424. coroutine.wrap(function()
  425. for i = 0, 20 do
  426. clone.Transparency = clone.Transparency + 0.05
  427. clone.Mesh.Scale = clone.Mesh.Scale - Vector3.new(0.05, 0.05, 0.05)
  428. wait()
  429. end
  430. clone:Destroy()
  431. end)()
  432. end
  433. wait()
  434. end
Add Comment
Please, Sign In to add comment