Advertisement
bmrx13

staff

Sep 28th, 2018
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 46.35 KB | None | 0 0
  1.  
  2. if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
  3. local Player,game,owner = owner,game
  4. local RealPlayer = Player
  5. do
  6. print("FE Compatibility code by Mokiros")
  7. local rp = RealPlayer
  8. script.Parent = rp.Character
  9.  
  10. --RemoteEvent for communicating
  11. local Event = Instance.new("RemoteEvent")
  12. Event.Name = "UserInput_Event"
  13.  
  14. --Fake event to make stuff like Mouse.KeyDown work
  15. local function fakeEvent()
  16. local t = {_fakeEvent=true,Functions={},Connect=function(self,f)table.insert(self.Functions,f) end}
  17. t.connect = t.Connect
  18. return t
  19. end
  20.  
  21. --Creating fake input objects with fake variables
  22. local m = {Target=nil,Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent(),Button2Up=fakeEvent(),Button2Down=fakeEvent()}
  23. local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
  24. local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
  25. CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
  26. end}
  27. --Merged 2 functions into one by checking amount of arguments
  28. CAS.UnbindAction = CAS.BindAction
  29.  
  30. --This function will trigger the events that have been :Connect()'ed
  31. local function te(self,ev,...)
  32. local t = m[ev]
  33. if t and t._fakeEvent then
  34. for _,f in pairs(t.Functions) do
  35. f(...)
  36. end
  37. end
  38. end
  39. m.TrigEvent = te
  40. UIS.TrigEvent = te
  41.  
  42. Event.OnServerEvent:Connect(function(plr,io)
  43. if plr~=rp then return end
  44. m.Target = io.Target
  45. m.Hit = io.Hit
  46. if not io.isMouse then
  47. local b = io.UserInputState == Enum.UserInputState.Begin
  48. if io.UserInputType == Enum.UserInputType.MouseButton1 then
  49. return m:TrigEvent(b and "Button1Down" or "Button1Up")
  50. end
  51. if io.UserInputType == Enum.UserInputType.MouseButton2 then
  52. return m:TrigEvent(b and "Button2Down" or "Button2Up")
  53. end
  54. for _,t in pairs(CAS.Actions) do
  55. for _,k in pairs(t.Keys) do
  56. if k==io.KeyCode then
  57. t.Function(t.Name,io.UserInputState,io)
  58. end
  59. end
  60. end
  61. m:TrigEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
  62. UIS:TrigEvent(b and "InputBegan" or "InputEnded",io,false)
  63. end
  64. end)
  65. Event.Parent = NLS([==[
  66. local Player = game:GetService("Players").LocalPlayer
  67. local Event = script:WaitForChild("UserInput_Event")
  68.  
  69. local Mouse = Player:GetMouse()
  70. local UIS = game:GetService("UserInputService")
  71. local input = function(io,a)
  72. if a then return end
  73. --Since InputObject is a client-side instance, we create and pass table instead
  74. Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState,Hit=Mouse.Hit,Target=Mouse.Target})
  75. end
  76. UIS.InputBegan:Connect(input)
  77. UIS.InputEnded:Connect(input)
  78.  
  79. local h,t
  80. --Give the server mouse data 30 times every second, but only if the values changed
  81. --If player is not moving their mouse, client won't fire events
  82. while wait(1/30) do
  83. if h~=Mouse.Hit or t~=Mouse.Target then
  84. h,t=Mouse.Hit,Mouse.Target
  85. Event:FireServer({isMouse=true,Target=t,Hit=h})
  86. end
  87. end]==],Player.Character)
  88.  
  89. ----Sandboxed game object that allows the usage of client-side methods and services
  90. --Real game object
  91. local _rg = game
  92.  
  93. --Metatable for fake service
  94. local fsmt = {
  95. __index = function(self,k)
  96. local s = rawget(self,"_RealService")
  97. if s then
  98. return typeof(s[k])=="function"
  99. and function(_,...)return s[k](s,...)end or s[k]
  100. end
  101. end,
  102. __newindex = function(self,k,v)
  103. local s = rawget(self,"_RealService")
  104. if s then s[k]=v end
  105. end
  106. }
  107. local function FakeService(t,RealService)
  108. t._RealService = typeof(RealService)=="string" and _rg:GetService(RealService) or RealService
  109. return setmetatable(t,fsmt)
  110. end
  111.  
  112. --Fake game object
  113. local g = {
  114. GetService = function(self,s)
  115. return rawget(self,s) or _rg:GetService(s)
  116. end,
  117. Players = FakeService({
  118. LocalPlayer = FakeService({GetMouse=function(self)return m end},Player)
  119. },"Players"),
  120. UserInputService = FakeService(UIS,"UserInputService"),
  121. ContextActionService = FakeService(CAS,"ContextActionService"),
  122. RunService = FakeService({
  123. _btrs = {},
  124. RenderStepped = _rg:GetService("RunService").Heartbeat,
  125. BindToRenderStep = function(self,name,_,fun)
  126. self._btrs[name] = self.Heartbeat:Connect(fun)
  127. end,
  128. UnbindFromRenderStep = function(self,name)
  129. self._btrs[name]:Disconnect()
  130. end,
  131. },"RunService")
  132. }
  133. rawset(g.Players,"localPlayer",g.Players.LocalPlayer)
  134. g.service = g.GetService
  135. FakeService(g,game)
  136. --Changing owner to fake player object to support owner:GetMouse()
  137. game,owner = g,g.Players.LocalPlayer
  138. end
  139. function sandbox(var,func)
  140. local env = getfenv(func)
  141. local newenv = setmetatable({},{
  142. __index = function(self,k)
  143. if k=="script" then
  144. return var
  145. else
  146. return env[k]
  147. end
  148. end,
  149. })
  150. setfenv(func,newenv)
  151. return func
  152. end
  153. cors = {}
  154. mas = Instance.new("Model",game:GetService("Lighting"))
  155. Tool0 = Instance.new("Tool")
  156. Part1 = Instance.new("Part")
  157. SpecialMesh2 = Instance.new("SpecialMesh")
  158. PointLight3 = Instance.new("PointLight")
  159. ParticleEmitter4 = Instance.new("ParticleEmitter")
  160. Sound5 = Instance.new("Sound")
  161. Sound6 = Instance.new("Sound")
  162. Sound7 = Instance.new("Sound")
  163. Sound8 = Instance.new("Sound")
  164. LocalScript9 = Instance.new("LocalScript")
  165. LocalScript10 = Instance.new("LocalScript")
  166. Animation11 = Instance.new("Animation")
  167. Animation12 = Instance.new("Animation")
  168. Animation13 = Instance.new("Animation")
  169. Script14 = Instance.new("Script")
  170. ScreenGui15 = Instance.new("ScreenGui")
  171. Frame16 = Instance.new("Frame")
  172. Frame17 = Instance.new("Frame")
  173. Frame18 = Instance.new("Frame")
  174. Frame19 = Instance.new("Frame")
  175. Frame20 = Instance.new("Frame")
  176. TextLabel21 = Instance.new("TextLabel")
  177. Script22 = Instance.new("Script")
  178. Tool0.Name = "Mystical Staff of Cyan Lightning Magic"
  179. Tool0.Parent = mas
  180. Tool0.TextureId = "http://www.roblox.com/asset/?id=276092020"
  181. Part1.Name = "Handle"
  182. Part1.Parent = Tool0
  183. Part1.Rotation = Vector3.new(43.5200005, 89.9399948, 0.119999997)
  184. Part1.Locked = true
  185. Part1.FormFactor = Enum.FormFactor.Custom
  186. Part1.Size = Vector3.new(0.5, 6, 0.5)
  187. Part1.CFrame = CFrame.new(-28.4999981, 2.34399509, 152.000427, 0.00102147646, -2.19987669e-06, 0.999999404, 0.690043509, 0.723767221, -0.000703365542, -0.723767221, 0.690043867, 0.000740786083)
  188. Part1.BottomSurface = Enum.SurfaceType.Smooth
  189. Part1.TopSurface = Enum.SurfaceType.Smooth
  190. Part1.Position = Vector3.new(-28.4999981, 2.34399509, 152.000427)
  191. Part1.Orientation = Vector3.new(0.0399999991, 89.9599991, 43.6299973)
  192. SpecialMesh2.Parent = Part1
  193. SpecialMesh2.MeshId = "http://www.roblox.com/asset/?id=276091747"
  194. SpecialMesh2.TextureId = "http://www.roblox.com/asset/?id=276091966"
  195. SpecialMesh2.MeshType = Enum.MeshType.FileMesh
  196. PointLight3.Parent = Part1
  197. PointLight3.Color = Color3.new(0, 1, 1)
  198. PointLight3.Brightness = 50
  199. PointLight3.Range = 6
  200. PointLight3.Color = Color3.new(0, 1, 1)
  201. ParticleEmitter4.Name = "Particles"
  202. ParticleEmitter4.Parent = Part1
  203. ParticleEmitter4.Transparency = NumberSequence.new(0.60000002384186,0.60000002384186)
  204. ParticleEmitter4.Rotation = NumberRange.new(0, 5)
  205. ParticleEmitter4.Size = NumberSequence.new(0.31999999284744,1.1799999475479,1.25)
  206. ParticleEmitter4.Color = ColorSequence.new(Color3.new(0, 1, 1),Color3.new(0, 0.666667, 1))
  207. ParticleEmitter4.LightEmission = 1
  208. ParticleEmitter4.Texture = "rbxasset://textures/particles/fire_main.dds"
  209. ParticleEmitter4.Acceleration = Vector3.new(0, 10, 0)
  210. ParticleEmitter4.Lifetime = NumberRange.new(0.20000000298023, 0.30000001192093)
  211. ParticleEmitter4.Rate = 1000
  212. ParticleEmitter4.RotSpeed = NumberRange.new(15, 25)
  213. ParticleEmitter4.Speed = NumberRange.new(-0.25, -0.25)
  214. ParticleEmitter4.Color = ColorSequence.new(Color3.new(0, 1, 1),Color3.new(0, 0.666667, 1))
  215. Sound5.Name = "Strike"
  216. Sound5.Parent = Part1
  217. Sound5.Pitch = 2
  218. Sound5.SoundId = "http://www.roblox.com/asset/?id=115327352"
  219. Sound5.Volume = 0.73460847139359
  220. Sound5.Looped = true
  221. Sound6.Name = "Lightning"
  222. Sound6.Parent = Part1
  223. Sound6.SoundId = "http://www.roblox.com/asset/?id=156190087"
  224. Sound6.Volume = 1
  225. Sound7.Name = "Zap"
  226. Sound7.Parent = Part1
  227. Sound7.Pitch = 1.25
  228. Sound7.SoundId = "http://www.roblox.com/asset/?id=156190087"
  229. Sound7.Volume = 1
  230. Sound8.Name = "Lightning2"
  231. Sound8.Parent = Part1
  232. Sound8.SoundId = "http://www.roblox.com/asset/?id=96478426"
  233. Sound8.Volume = 1
  234. LocalScript9.Parent = Tool0
  235. table.insert(cors,sandbox(LocalScript9,function()
  236. --Made by Luckymaxer
  237.  
  238. Tool = script.Parent
  239. Handle = Tool:WaitForChild("Handle")
  240.  
  241. Players = game:GetService("Players")
  242. RunService = game:GetService("RunService")
  243. ContentProvider = game:GetService("ContentProvider")
  244.  
  245. RbxUtility = LoadLibrary("RbxUtility")
  246. Create = RbxUtility.Create
  247.  
  248. Animations = {}
  249.  
  250. ServerControl = Tool:WaitForChild("ServerControl")
  251. ClientControl = Tool:WaitForChild("ClientControl")
  252.  
  253. Rate = (1 / 60)
  254.  
  255. MobilityDisabled = false
  256. ToolEquipped = false
  257.  
  258. function SetAnimation(mode, value)
  259. if not ToolEquipped or not CheckIfAlive() then
  260. return
  261. end
  262. local function StopAnimation(Animation)
  263. for i, v in pairs(Animations) do
  264. if v.Animation == Animation then
  265. v.AnimationTrack:Stop(value.EndFadeTime)
  266. for i, v in pairs({v.KeyframeReached, v.TrackStopped}) do
  267. if v then
  268. v:disconnect()
  269. end
  270. end
  271. table.remove(Animations, i)
  272. end
  273. end
  274. end
  275. if mode == "PlayAnimation" then
  276. for i, v in pairs(Animations) do
  277. if v.Animation == value.Animation then
  278. if value.Speed then
  279. v.AnimationTrack:AdjustSpeed(value.Speed)
  280. return
  281. elseif value.Weight or value.FadeTime then
  282. v.AnimationTrack:AdjustWeight(value.Weight, value.FadeTime)
  283. return
  284. else
  285. StopAnimation(value.Animation, false)
  286. end
  287. end
  288. end
  289. local AnimationMonitor = Create("Model"){}
  290. local TrackEnded = Create("StringValue"){Name = "Ended"}
  291. local AnimationTrack = Humanoid:LoadAnimation(value.Animation)
  292. local TrackStopped, KeyframeReached
  293. if value.PauseAt then
  294. KeyframeReached = AnimationTrack.KeyframeReached:connect(function(Keyframe)
  295. if Keyframe == value.PauseAt then
  296. AnimationTrack:AdjustSpeed(0)
  297. if KeyframeReached then
  298. KeyframeReached:disconnect()
  299. end
  300. end
  301. end)
  302. end
  303. if not value.Manual then
  304. TrackStopped = AnimationTrack.Stopped:connect(function()
  305. if TrackStopped then
  306. TrackStopped:disconnect()
  307. end
  308. StopAnimation(value.Animation, true)
  309. TrackEnded.Parent = AnimationMonitor
  310. end)
  311. end
  312. table.insert(Animations, {Animation = value.Animation, AnimationTrack = AnimationTrack, KeyframeReached = KeyframeReached, TrackStopped = TrackStopped})
  313. AnimationTrack:Play(value.FadeTime, value.Weight, value.Speed)
  314. if TrackStopped then
  315. AnimationMonitor:WaitForChild(TrackEnded.Name)
  316. end
  317. return TrackEnded.Name
  318. elseif mode == "StopAnimation" and value then
  319. StopAnimation(value.Animation)
  320. end
  321. end
  322.  
  323. function DisableMobility(Boolean)
  324. if Boolean and MobilityDisabled then
  325. return
  326. end
  327. if MobilityDisabler then
  328. MobilityDisabler:disconnect()
  329. end
  330. MobilityDisabled = Boolean
  331. if MobilityDisabled then
  332. Humanoid.AutoRotate = false
  333. Humanoid.WalkSpeed = 0
  334. MobilityDisabler = Humanoid.Changed:connect(function(Property)
  335. Humanoid.Jump = false
  336. Humanoid.AutoRotate = false
  337. Humanoid.WalkSpeed = 0
  338. end)
  339. else
  340. Humanoid.AutoRotate = true
  341. Humanoid.WalkSpeed = 16
  342. end
  343. end
  344.  
  345. function CheckIfAlive()
  346. return (((Character and Character.Parent and Humanoid and Humanoid.Parent and Humanoid.Health > 0 and Player and Player.Parent) and true) or false)
  347. end
  348.  
  349. function Equipped(Mouse)
  350. Character = Tool.Parent
  351. Player = Players:GetPlayerFromCharacter(Character)
  352. Humanoid = Character:FindFirstChild("Humanoid")
  353. ToolEquipped = true
  354. if not CheckIfAlive() then
  355. return
  356. end
  357. Spawn(function()
  358. PlayerMouse = Player:GetMouse()
  359. Mouse.Button1Down:connect(function()
  360. InvokeServer("Button1Click", {Down = true})
  361. end)
  362. Mouse.Button1Up:connect(function()
  363. InvokeServer("Button1Click", {Down = false})
  364. end)
  365. Mouse.KeyDown:connect(function(Key)
  366. InvokeServer("KeyPress", {Key = Key, Down = true})
  367. end)
  368. Mouse.KeyUp:connect(function(Key)
  369. InvokeServer("KeyPress", {Key = Key, Down = false})
  370. end)
  371. for i, v in pairs(Tool:GetChildren()) do
  372. if v:IsA("Animation") then
  373. ContentProvider:Preload(v.AnimationId)
  374. end
  375. end
  376. end)
  377. end
  378.  
  379. function Unequipped()
  380. for i, v in pairs(Animations) do
  381. if v and v.AnimationTrack then
  382. v.AnimationTrack:Stop()
  383. end
  384. end
  385. DisableMobility(false)
  386. Animations = {}
  387. ToolEquipped = false
  388. end
  389.  
  390. function InvokeServer(mode, value)
  391. local ServerReturn = nil
  392. pcall(function()
  393. ServerReturn = ServerControl:InvokeServer(mode, value)
  394. end)
  395. return ServerReturn
  396. end
  397.  
  398. function OnClientInvoke(mode, value)
  399. if mode == "PlayAnimation" and value and ToolEquipped and Humanoid then
  400. SetAnimation("PlayAnimation", value)
  401. elseif mode == "StopAnimation" and value then
  402. SetAnimation("StopAnimation", value)
  403. elseif mode == "PlaySound" and value then
  404. value:Play()
  405. elseif mode == "StopSound" and value then
  406. value:Stop()
  407. elseif mode == "MousePosition" then
  408. return {Position = PlayerMouse.Hit.p, Target = PlayerMouse.Target}
  409. elseif mode == "SetMouse" then
  410. pcall(function()
  411. Mouse[value.Property] = value.Value
  412. end)
  413. elseif mode == "DisableMobility" then
  414. local Disabled = value.Disabled
  415. DisableMobility(value.Disabled)
  416. end
  417. end
  418.  
  419. ClientControl.OnClientInvoke = OnClientInvoke
  420. Tool.Equipped:connect(Equipped)
  421. Tool.Unequipped:connect(Unequipped)
  422. end))
  423. LocalScript10.Name = "MouseIcon"
  424. LocalScript10.Parent = Tool0
  425. table.insert(cors,sandbox(LocalScript10,function()
  426. --Made by Luckymaxer
  427.  
  428. Mouse_Icon = "rbxasset://textures/GunCursor.png"
  429. Reloading_Icon = "rbxasset://textures/GunWaitCursor.png"
  430.  
  431. Tool = script.Parent
  432.  
  433. Mouse = nil
  434.  
  435. function UpdateIcon()
  436. if Mouse then
  437. Mouse.Icon = Tool.Enabled and Mouse_Icon or Reloading_Icon
  438. end
  439. end
  440.  
  441. function OnEquipped(ToolMouse)
  442. Mouse = ToolMouse
  443. UpdateIcon()
  444. end
  445.  
  446. function OnChanged(Property)
  447. if Property == "Enabled" then
  448. UpdateIcon()
  449. end
  450. end
  451.  
  452. Tool.Equipped:connect(OnEquipped)
  453. Tool.Changed:connect(OnChanged)
  454.  
  455. end))
  456. Animation11.Name = "Blast"
  457. Animation11.Parent = Tool0
  458. Animation11.AnimationId = "http://www.roblox.com/asset/?id=277780975"
  459. Animation12.Name = "ArmsUp"
  460. Animation12.Parent = Tool0
  461. Animation12.AnimationId = "http://www.roblox.com/asset/?id=280211525"
  462. Animation13.Name = "Spin"
  463. Animation13.Parent = Tool0
  464. Animation13.AnimationId = "http://www.roblox.com/asset/?id=232937965"
  465. Script14.Parent = Tool0
  466. table.insert(cors,sandbox(Script14,function()
  467. --Made by Luckymaxer
  468.  
  469. Tool = script.Parent
  470. Handle = Tool:WaitForChild("Handle")
  471.  
  472. Players = game:GetService("Players")
  473. Debris = game:GetService("Debris")
  474. RunService = game:GetService("RunService")
  475.  
  476. LightningFunctions = require(script:WaitForChild("LightningFunctions"))
  477.  
  478. RbxUtility = LoadLibrary("RbxUtility")
  479. Create = RbxUtility.Create
  480.  
  481. BaseUrl = "http://www.roblox.com/asset/?id="
  482.  
  483. Gravity = 196.20
  484. Rate = (1 / 60)
  485.  
  486. BasePart = Create("Part"){
  487. Material = Enum.Material.Plastic,
  488. Shape = Enum.PartType.Block,
  489. TopSurface = Enum.SurfaceType.Smooth,
  490. BottomSurface = Enum.SurfaceType.Smooth,
  491. FormFactor = Enum.FormFactor.Custom,
  492. Size = Vector3.new(0.2, 0.2, 0.2),
  493. CanCollide = true,
  494. Locked = true,
  495. }
  496.  
  497. ManaBar = script:WaitForChild("ManaBar")
  498.  
  499. Animations = {
  500. Blast = {Animation = Tool:WaitForChild("Blast"), FadeTime = nil, Weight = nil, Speed = 1, Duration = 1.5, PauseAt = "Complete"},
  501. ArmsUp = {Animation = Tool:WaitForChild("ArmsUp"), FadeTime = nil, Weight = nil, Speed = 1, Duration = 1},
  502. Spin = {Animation = Tool:WaitForChild("Spin"), FadeTime = nil, Weight = nil, Speed = 1, Duration = 0.5},
  503. }
  504.  
  505. Sounds = {
  506. Lightning = Handle:WaitForChild("Lightning"),
  507. Lightning2 = Handle:WaitForChild("Lightning2"),
  508. Strike = Handle:WaitForChild("Strike"),
  509. Zap = Handle:WaitForChild("Zap"),
  510.  
  511. }
  512.  
  513. CurrentMana = Create("DoubleConstrainedValue"){
  514. MinValue = 0,
  515. MaxValue = 0,
  516. }
  517. CurrentMana.Value = (CurrentMana.MaxValue * 0.75)
  518. ManaCharging = Create("BoolValue"){
  519. Value = false,
  520. }
  521.  
  522. InUse = Create("BoolValue"){
  523. Value = false,
  524. }
  525. MouseDown = Create("BoolValue"){
  526. Value = false,
  527. }
  528. ToolEquipped = Create("BoolValue"){
  529. Value = false,
  530. }
  531.  
  532. ServerControl = (Tool:FindFirstChild("ServerControl") or Create("RemoteFunction"){
  533. Name = "ServerControl",
  534. Parent = Tool,
  535. })
  536.  
  537. ClientControl = (Tool:FindFirstChild("ClientControl") or Create("RemoteFunction"){
  538. Name = "ClientControl",
  539. Parent = Tool,
  540. })
  541.  
  542. Handle.Transparency = 0
  543. Tool.Enabled = true
  544.  
  545. function IsTeamMate(Player1, Player2)
  546. return (Player1 and Player2 and not Player1.Neutral and not Player2.Neutral and Player1.TeamColor == Player2.TeamColor)
  547. end
  548.  
  549. function TagHumanoid(humanoid, player)
  550. local Creator_Tag = Create("ObjectValue"){
  551. Name = "creator",
  552. Value = player,
  553. }
  554. Debris:AddItem(Creator_Tag, 2)
  555. Creator_Tag.Parent = humanoid
  556. end
  557.  
  558. function UntagHumanoid(humanoid)
  559. for i, v in pairs(humanoid:GetChildren()) do
  560. if v:IsA("ObjectValue") and v.Name == "creator" then
  561. v:Destroy()
  562. end
  563. end
  564. end
  565.  
  566. function TakeDamage(humanoid, Damage)
  567. if not humanoid or not humanoid:IsA("Humanoid") or not Damage or not Player then
  568. return
  569. end
  570. local character = humanoid.Parent
  571. for i, v in pairs(character:GetChildren()) do
  572. if v:IsA("ForceField") then
  573. return
  574. end
  575. end
  576. local player = Players:GetPlayerFromCharacter(Character)
  577. if player then
  578. if IsTeamMate(Player, player) then
  579. return
  580. end
  581. CurrentMana.Value = CurrentMana.Value + (CurrentMana.MaxValue * 0.02)
  582. end
  583. TagHumanoid(humanoid, Player)
  584. humanoid:TakeDamage(Damage)
  585. UntagHumanoid(humanoid)
  586. end
  587.  
  588. function Clamp(Number, Min, Max)
  589. return math.max(math.min(Max, Number), Min)
  590. end
  591.  
  592. function GetPercentage(Start, End, Number)
  593. return (((Number - Start) / (End - Start)) * 100)
  594. end
  595.  
  596. function Round(Number, RoundDecimal)
  597. local WholeNumber, Decimal = math.modf(Number)
  598. return ((Decimal >= RoundDecimal and math.ceil(Number)) or (Decimal < RoundDecimal and math.floor(Number)))
  599. end
  600.  
  601. function MakeCircle(Origin, Radius, Parts)
  602. local Circle = Create("Model"){
  603. Name = "Circle",
  604. }
  605. for i = 1, Parts do
  606. local Part = BasePart:Clone()
  607. Part.Name = "Effect"
  608. Part.Transparency = 1
  609. Part.Size = Vector3.new(6, 0.2, (Radius * 2))
  610. Part.Anchored = true
  611. Part.CanCollide = false
  612. Part.CFrame = (Origin * CFrame.Angles(0, ((math.pi * 2) / (Parts / i)), 0))
  613. Part.CFrame = (Part.CFrame + Part.CFrame.lookVector * (Radius / 2))
  614. Part.Parent = Circle
  615. end
  616. return Circle
  617. end
  618.  
  619. function CheckTableForInstance(Table, Instance)
  620. for i, v in pairs(Table) do
  621. if v == Instance then
  622. return true
  623. end
  624. end
  625. return false
  626. end
  627.  
  628. function GetAllConnectedParts(Object)
  629. local Parts = {}
  630. local function GetConnectedParts(Object)
  631. for i, v in pairs(Object:GetConnectedParts()) do
  632. local Ignore = false
  633. for ii, vv in pairs(Parts) do
  634. if v == vv then
  635. Ignore = true
  636. end
  637. end
  638. if not Ignore then
  639. table.insert(Parts, v)
  640. GetConnectedParts(v)
  641. end
  642. end
  643. end
  644. GetConnectedParts(Object)
  645. return Parts
  646. end
  647.  
  648. function GetTotalParts(MaxParts, PossibleParts, Parts)
  649. if MaxParts < PossibleParts then
  650. return MaxParts
  651. elseif Parts >= MaxParts then
  652. return 0
  653. elseif MaxParts >= PossibleParts then
  654. local PartCount = (MaxParts - PossibleParts)
  655. if Parts <= MaxParts then
  656. PartCount = (MaxParts - Parts)
  657. if PartCount > PossibleParts then
  658. return PossibleParts
  659. else
  660. return PartCount
  661. end
  662. elseif PartCount >= PossibleParts then
  663. return PossibleParts
  664. else
  665. return PartCount
  666. end
  667. end
  668. end
  669.  
  670. function GetParts(Region, MaxParts, Ignore)
  671. local Parts = {}
  672. local RerunFailed = false
  673. while #Parts < MaxParts and not RerunFailed do
  674. local Region = Region
  675. local PossibleParts = GetTotalParts(MaxParts, 100, #Parts)
  676. local PartsNearby = game:GetService("Workspace"):FindPartsInRegion3WithIgnoreList(Region, Ignore, PossibleParts)
  677. if #PartsNearby == 0 then
  678. RerunFailed = true
  679. else
  680. for i, v in pairs(PartsNearby) do
  681. table.insert(Parts, v)
  682. table.insert(Ignore, v)
  683. end
  684. end
  685. end
  686. return Parts
  687. end
  688.  
  689. function GetNearbyObjects(Region)
  690. local IgnoreList = {Character}
  691. for i, v in pairs(Players:GetChildren()) do
  692. if v:IsA("Player") and v ~= Player and v.Character and v.Character.Parent and IsTeamMate(Player, v) then
  693. table.insert(IgnoreList, v.Character)
  694. end
  695. end
  696. return GetParts(Region, 500, IgnoreList)
  697. end
  698.  
  699. function ManageMana(Gui)
  700. local Mana = {}
  701. if not Gui then
  702. return
  703. end
  704. local Frame = Gui:FindFirstChild("Frame")
  705. if not Frame then
  706. return
  707. end
  708. local Bar = Frame:FindFirstChild("Bar")
  709. if not Bar then
  710. return
  711. end
  712. local function AdjustBar()
  713. local ChargePercent = (GetPercentage(0, 100, CurrentMana.Value) * 0.01)
  714. local NewMana = Clamp((Frame.AbsoluteSize.X * ChargePercent), 0, Frame.AbsoluteSize.X)
  715. Bar.Size = (UDim2.new(Bar.Size.X.Scale, 0, Bar.Size.Y.Scale, Bar.Size.Y.Offset) + UDim2.new(0, NewMana, 0, 0))
  716. end
  717. for i, v in pairs({ToolUnequipped, ManaAltered}) do
  718. if v then
  719. v:disconnect()
  720. end
  721. end
  722. local CurrentlyEquipped = true
  723. ToolUnequipped = Tool.Unequipped:connect(function()
  724. CurrentlyEquipped = false
  725. end)
  726. ManaAltered = CurrentMana.Changed:connect(function()
  727. AdjustBar()
  728. end)
  729. function Mana:UseMana(Amount)
  730. CurrentMana.Value = (CurrentMana.Value - Amount)
  731. if CurrentMana.Value < CurrentMana.MaxValue and not ManaCharging.Value then
  732. ManaCharging.Value = true
  733. end
  734. end
  735. AdjustBar()
  736. return Mana
  737. end
  738.  
  739. function ChargeMana()
  740. --[[if not ManaCharging.Value then
  741. return
  742. end]]
  743. Spawn(function()
  744. local ChargeTimeRate = 0.001
  745. local ChargeRate = 0.001
  746. local ChargePercent = 100
  747. while --[[ManaCharging.Value and CurrentMana.Value < CurrentMana.MaxValue]]true do
  748. wait(ChargeTimeRate)
  749. --if not InUse.Value then
  750. CurrentMana.Value = (CurrentMana.Value + ((CurrentMana.MaxValue * ChargePercent) * ChargeRate))
  751. --end
  752. end
  753. --ManaCharging.Value = false
  754. end)
  755. end
  756.  
  757. function CreateStaff(CreateNew)
  758. for i, v in pairs(Tool:GetChildren()) do
  759. if v:IsA("BasePart") and v ~= Handle then
  760. v:Destroy()
  761. end
  762. end
  763. Handle.Transparency = ((CreateNew and 1) or 0)
  764. if not CreateNew then
  765. return
  766. end
  767. Staff = BasePart:Clone()
  768. Staff.Name = "Staff"
  769. Staff.Size = Vector3.new(0.5, 6, 0.5)
  770. Staff.CanCollide = false
  771. local Mesh = Create("SpecialMesh"){
  772. Name = "Mesh",
  773. MeshType = Enum.MeshType.FileMesh,
  774. MeshId = (BaseUrl .. "276091843"),
  775. TextureId = (BaseUrl .. "276091966"),
  776. Scale = Vector3.new(1, 1, 1),
  777. Parent = Staff,
  778. }
  779. GripPiece = Staff:Clone()
  780. GripPiece.Name = "GripPiece"
  781. GripPiece.Size = Vector3.new(0.5, 1.5, 0.5)
  782. GripPiece.Mesh.MeshId = (BaseUrl .. "276091878")
  783. Orb = Staff:Clone()
  784. Orb.Name = "Orb"
  785. Orb.Size = Vector3.new(0.2, 0.2, 0.2)
  786. Orb.Mesh.MeshId = (BaseUrl .. "276091920")
  787. local Joints = {
  788. {Class = "Weld", Parent = Staff, Properties = {Part0 = Handle, Part1 = Staff, C0 = CFrame.new(0, 0, 0), C1 = CFrame.new(0, 0, 0)}},
  789. {Class = "Weld", Parent = Staff, Properties = {Part0 = Staff, Part1 = GripPiece, C0 = CFrame.new(-0.05, 1.925, -0.0375), C1 = CFrame.new(0, 0, 0)}},
  790. {Class = "Motor6D", Parent = Staff, Properties = {Part0 = GripPiece, Part1 = Orb, MaxVelocity = 0.05, DesiredAngle = 99999999, C0 = CFrame.new(-0.0225, 0.3, 0.0275), C1 = CFrame.new(0, 0, 0)}},
  791. }
  792. for i, v in pairs(Joints) do
  793. local Joint = Create(v.Class){}
  794. for ii, vv in pairs(v.Properties) do
  795. Joint[ii] = vv
  796. end
  797. Joint.Parent = v.Parent
  798. end
  799. for i, v in pairs({Staff, GripPiece, Orb}) do
  800. v.Parent = Tool
  801. end
  802. end
  803.  
  804. function CheckIfAlive()
  805. return (((Character and Character.Parent and Humanoid and Humanoid.Parent and Humanoid.Health > 0 and Torso and Torso.Parent and Player and Player.Parent) and true) or false)
  806. end
  807.  
  808. function Activated()
  809. if not Tool.Enabled or not ToolEquipped.Value or MouseDown.Value or not CheckIfAlive() or InUse.Value then
  810. return
  811. end
  812. Tool.Enabled = false
  813. MouseDown.Value = true
  814. local CurrentlyEquipped = true
  815. local CurrentlyDown = true
  816. local ToolUnequipped = Tool.Unequipped:connect(function()
  817. CurrentlyEquipped = false
  818. end)
  819. local MouseButtonUp = MouseDown.Changed:connect(function()
  820. if not MouseDown.Value then
  821. CurrentlyDown = false
  822. end
  823. end)
  824. InUse.Value = true
  825. Sounds.Lightning:Play()
  826. Delay(0.25, (function()
  827. for i, v in pairs({ToolUnequipped, MouseButtonUp}) do
  828. if v then
  829. v:disconnect()
  830. end
  831. end
  832. if CurrentlyEquipped and CurrentlyDown and CheckIfAlive() then
  833. Sounds.Strike:Play()
  834. end
  835. end))
  836. local ManaCost = 0
  837. local MaxDuration = 5
  838. local StartTime = tick()
  839. local StrikeCount = 0
  840. local LightningDamage = 999999999
  841. local FireRate = 0.001
  842. local LightningReloadTime = 0.001
  843. while CheckIfAlive() and ToolEquipped.Value and MouseDown.Value and Orb.Parent --[[and (tick() - StartTime) <= MaxDuration]] and CurrentMana.Value >= ManaCost do
  844. StrikeCount = (StrikeCount + 1)
  845. if StrikeCount > 1 then
  846. ManaUsage:UseMana(ManaCost)
  847. end
  848. Sounds.Strike.Volume = (((math.sin(tick() * 3) + 1) * 0.25) + 0.25)
  849. local MousePosition = InvokeClient("MousePosition")
  850. if MousePosition then
  851. MousePosition = MousePosition.Position
  852. LightningFunctions.RemoveLightning()
  853. local RayData = LightningFunctions.Zap({StartPosition = Orb.Position, TargetPosition = MousePosition, Character = Character, Color = "Cyan", Individual = false})
  854. if RayData then
  855. local RayHit = RayData.RayHit
  856. if RayHit then
  857. local character = RayHit.Parent
  858. if character == Character then
  859. return
  860. end
  861. if character:IsA("Hat") then
  862. character = character.Parent
  863. end
  864. local humanoid = character:FindFirstChild("Humanoid")
  865. if humanoid and humanoid.Health > 0 then
  866. local player = Players:GetPlayerFromCharacter(character)
  867. if not player or (player and not IsTeamMate(Player, player)) then
  868. UntagHumanoid(humanoid)
  869. TagHumanoid(humanoid, Player)
  870. humanoid:TakeDamage(LightningDamage)
  871. end
  872. end
  873. end
  874. Spawn(function()
  875. InvokeClient("SetMouse", {Property = "TargetFilter", Value = RayData.LightningModel})
  876. end)
  877. end
  878. end
  879. wait(FireRate)
  880. end
  881. InUse.Value = false
  882. Sounds.Strike:Stop()
  883. if StrikeCount > 1 then
  884. wait(LightningReloadTime)
  885. else
  886. wait(LightningReloadTime / 4)
  887. end
  888. Tool.Enabled = true
  889. end
  890.  
  891. function ResetStuff()
  892. for i, v in pairs({ManaBarCopy, ManaAltered, ToolUnequipped}) do
  893. if v then
  894. if tostring(v) == "Connection" then
  895. v:disconnect()
  896. elseif type(v) == "userdata" and v.Parent then
  897. v:Destroy()
  898. end
  899. end
  900. end
  901. for i, v in pairs(Sounds) do
  902. v:Stop()
  903. end
  904. for i, v in pairs({InUse, MouseDown}) do
  905. v.Value = false
  906. end
  907. end
  908.  
  909. function Equipped(Mouse)
  910. Character = Tool.Parent
  911. Humanoid = Character:FindFirstChild("Humanoid")
  912. Torso = Character:FindFirstChild("Torso")
  913. Player = Players:GetPlayerFromCharacter(Character)
  914. if not CheckIfAlive() then
  915. return
  916. end
  917. Spawn(function()
  918. EquipTick = tick()
  919. ResetStuff()
  920. --[[if CurrentMana.Value >= (CurrentMana.MaxValue * 0.8) then
  921. CurrentMana.Value = (CurrentMana.MaxValue * 0.8)
  922. end]]
  923. CreateStaff(true)
  924. local PlayerGui = Player:FindFirstChild("PlayerGui")
  925. if PlayerGui then
  926. ManaBarCopy = ManaBar:Clone()
  927. ManaUsage = ManageMana(ManaBarCopy)
  928. ManaBarCopy.Parent = PlayerGui
  929. end
  930. end)
  931. ToolEquipped.Value = true
  932. end
  933.  
  934. function Unequipped()
  935. ResetStuff()
  936. CreateStaff(false)
  937. ToolEquipped.Value = false
  938. end
  939.  
  940. function OnServerInvoke(player, mode, value)
  941. if player ~= Player or not ToolEquipped.Value or not value or not CheckIfAlive() then
  942. return
  943. end
  944. if mode == "Button1Click" then
  945. local Down = value.Down
  946. if not Down and MouseDown.Value then
  947. MouseDown.Value = false
  948. end
  949. elseif mode == "KeyPress" then
  950. local Key = value.Key
  951. local Down = value.Down
  952. if Down and Tool.Enabled and not InUse.Value then
  953. if Key == "z" then
  954. local ManaCost = 0
  955. if CurrentMana.Value < ManaCost or (tick() - EquipTick) < 5 then
  956. return
  957. end
  958. ManaUsage:UseMana(ManaCost)
  959. Tool.Enabled = false
  960. InUse.Value = true
  961. local PlayersNearby = {}
  962. for i, v in pairs(Players:GetChildren()) do
  963. if v:IsA("Player") and v ~= Player and not IsTeamMate(Player, v) and v.Character then
  964. local character = v.Character
  965. local ForceField = nil
  966. for i, v in pairs(character:GetChildren()) do
  967. if v:IsA("ForceField") then
  968. ForceField = v
  969. break
  970. end
  971. end
  972. if not ForceField then
  973. local torso = character:FindFirstChild("Torso")
  974. table.insert(PlayersNearby, v)
  975. end
  976. end
  977. end
  978. local ClosestPlayer = {Player = nil, Distance = 40}
  979. for i, v in pairs(PlayersNearby) do
  980. local character = v.Character
  981. local torso = character:FindFirstChild("Torso")
  982. if torso then
  983. local DistanceApart = (Torso.Position - torso.Position).Magnitude
  984. if DistanceApart < ClosestPlayer.Distance then
  985. ClosestPlayer.Player = character
  986. ClosestPlayer.Distance = DistanceApart
  987. end
  988. end
  989. end
  990. if not ClosestPlayer.Player then
  991. local HumanoidsHit = {}
  992. local NPCsNearby = {}
  993. local LightningRadius = ClosestPlayer.Distance
  994. local LightningRegion = Region3.new((Torso.Position - Vector3.new(LightningRadius, LightningRadius, LightningRadius)), (Torso.Position + Vector3.new(LightningRadius, LightningRadius, LightningRadius)))
  995. for i, v in pairs(GetNearbyObjects(LightningRegion)) do
  996. if v and v.Parent then
  997. local character = v.Parent
  998. if character ~= Character then
  999. local humanoid = character:FindFirstChild("Humanoid")
  1000. if humanoid and humanoid.Health > 0 then
  1001. local player = Players:GetPlayerFromCharacter(character)
  1002. if not player then
  1003. if not CheckTableForInstance(HumanoidsHit, humanoid) then
  1004. local ForceField = nil
  1005. for ii, vv in pairs(character:GetChildren()) do
  1006. if vv:IsA("ForceField") then
  1007. ForceField = vv
  1008. break
  1009. end
  1010. end
  1011. if not ForceField then
  1012. table.insert(NPCsNearby, character)
  1013. end
  1014. end
  1015. end
  1016. end
  1017. end
  1018. end
  1019. end
  1020. for i, v in pairs(NPCsNearby) do
  1021. local torso = v:FindFirstChild("Torso")
  1022. if torso then
  1023. local DistanceApart = (Torso.Position - torso.Position).Magnitude
  1024. if DistanceApart < ClosestPlayer.Distance then
  1025. ClosestPlayer.Player = v
  1026. ClosestPlayer.Distance = DistanceApart
  1027. end
  1028. end
  1029. end
  1030. end
  1031. if ClosestPlayer.Player then
  1032. local character = ClosestPlayer.Player
  1033. local humanoid = character:FindFirstChild("Humanoid")
  1034. local torso = character:FindFirstChild("Torso")
  1035. if humanoid and humanoid.Health > 0 and torso then
  1036. local StartPosition = (CFrame.new(torso.Position) * CFrame.new(0, 50, 0))
  1037. local TargetPosition = (StartPosition + Vector3.new(0, -1, 0) * 75)
  1038. local RayData = LightningFunctions.Zap({StartPosition = StartPosition.p, TargetPosition = TargetPosition.p, Character = Character, Color = "Cyan", Individual = true, Duration = 2, TimeToFade = 1, MaxRange = 150, SegmentLength = 5, Ignore = {character}})
  1039. for i = 1, 4 do
  1040. Spawn(function()
  1041. LightningFunctions.Zap({StartPosition = StartPosition.p, TargetPosition = TargetPosition.p, Character = Character, Color = "Cyan", Individual = true, Duration = 2, TimeToFade = 1, MaxRange = 150, SegmentLength = 5, Ignore = {character}})
  1042. end)
  1043. end
  1044. if RayData then
  1045. local RayPos = RayData.RayPos
  1046. local SoundPart = BasePart:Clone()
  1047. SoundPart.Name = "Effect"
  1048. SoundPart.Transparency = 1
  1049. SoundPart.CanCollide = false
  1050. local Sound = Sounds.Lightning2:Clone()
  1051. Sound.Parent = SoundPart
  1052. Debris:AddItem(SoundPart, 2)
  1053. SoundPart.Parent = game:GetService("Workspace")
  1054. SoundPart.CFrame = CFrame.new(RayPos)
  1055. Sound:Play()
  1056. wait(0.1)
  1057. for i = 1, math.random(10, 15) do
  1058. local StartPosition = (CFrame.new(RayData.RayPos) * CFrame.new(0, 0, 0))
  1059. local TargetPosition = (StartPosition + Vector3.new((math.random(-360, 360) * 0.01), 1, (math.random(-360, 360) * 0.01)) * 2)
  1060. local Spark = LightningFunctions.Zap({StartPosition = StartPosition.p, TargetPosition = TargetPosition.p, Character = Character, Color = "Cyan", Individual = true, Duration = 1.9, TimeToFade = 0.9, MaxRange = (math.random(800, 1500) * 0.01), SegmentLength = (math.random(200, 1000) * 0.001), Ignore = {character}})
  1061. end
  1062. end
  1063. TakeDamage(humanoid, 999999999)
  1064. end
  1065. end
  1066. InUse.Value = false
  1067. Tool.Enabled = true
  1068. end
  1069. if Key == "x" then
  1070. local ManaCost = 0
  1071. if CurrentMana.Value < ManaCost then
  1072. return
  1073. end
  1074. ManaUsage:UseMana(ManaCost)
  1075. Tool.Enabled = false
  1076. InUse.Value = true
  1077. Sounds.Zap:Play()
  1078. local Animation = Animations.Spin
  1079. Spawn(function()
  1080. InvokeClient("StopAnimation", Animation)
  1081. InvokeClient("PlayAnimation", Animation)
  1082. end)
  1083. Spawn(function()
  1084. local Animation = Animations.ArmsUp
  1085. InvokeClient("StopAnimation", Animation)
  1086. InvokeClient("PlayAnimation", {Animation = Animation.Animation, FadeTime = Animation.FadeTime, Weight = Animation.Weight, Speed = 1.5})
  1087. end)
  1088. Spawn(function()
  1089. local WaitTime = (Animation.Duration / 10)
  1090. for i = 1, 10 do
  1091. if not ToolEquipped or not CheckIfAlive() then
  1092. return
  1093. end
  1094. local StartPosition = (Orb.CFrame * CFrame.new(0, 0, 0))
  1095. local TargetPosition = (StartPosition * CFrame.new((math.random(-100, 100) * 0.01), 0, (math.random(-500, 500) * 0.01)))
  1096. local RayData = LightningFunctions.Zap({StartPosition = StartPosition.p, TargetPosition = TargetPosition.p, Character = Character, Color = "Cyan", Individual = true, Duration = 2.5, MaxRange = 2, SegmentLength = 0.5})
  1097. wait(WaitTime)
  1098. end
  1099. end)
  1100. local HumanoidsHit = {}
  1101. local LightningRadius = 10
  1102. local LightningRegion = Region3.new((Torso.Position - Vector3.new(LightningRadius, LightningRadius, LightningRadius)), (Torso.Position + Vector3.new(LightningRadius, LightningRadius, LightningRadius)))
  1103. for i, v in pairs(GetNearbyObjects(LightningRegion)) do
  1104. if v and v.Parent then
  1105. local character = v.Parent
  1106. if character ~= Character then
  1107. local humanoid = character:FindFirstChild("Humanoid")
  1108. if humanoid and humanoid.Health > 0 then
  1109. local player = Players:GetPlayerFromCharacter(character)
  1110. if not player or (player and not IsTeamMate(Player, player)) then
  1111. if not CheckTableForInstance(HumanoidsHit, humanoid) then
  1112. local ForceField = nil
  1113. for ii, vv in pairs(character:GetChildren()) do
  1114. if vv:IsA("ForceField") then
  1115. ForceField = vv
  1116. break
  1117. end
  1118. end
  1119. if not ForceField then
  1120. table.insert(HumanoidsHit, humanoid)
  1121. TakeDamage(humanoid, 10)
  1122. local torso = character:FindFirstChild("Torso")
  1123. if torso then
  1124. humanoid.Sit = true
  1125. torso.Velocity = (CFrame.new(Torso.Position, torso.Position).lookVector * 50)
  1126. end
  1127. end
  1128. end
  1129. end
  1130. end
  1131. end
  1132. end
  1133. end
  1134. InUse.Value = false
  1135. Tool.Enabled = true
  1136. elseif Key == "q" then
  1137. local ManaCost = 0
  1138. if CurrentMana.Value < ManaCost then
  1139. return
  1140. end
  1141. Spawn(function()
  1142. InvokeClient("DisableMobility", {Disabled = true})
  1143. end)
  1144. local SpellDuration = 1
  1145. ManaUsage:UseMana(ManaCost)
  1146. Tool.Enabled = false
  1147. InUse.Value = true
  1148. local Animation = Animations.Blast
  1149. Spawn(function()
  1150. InvokeClient("StopAnimation", Animation)
  1151. InvokeClient("PlayAnimation", Animation)
  1152. end)
  1153. wait(Animation.Duration)
  1154. local TorsoCFrame = Torso.CFrame
  1155. local StartPoint = (TorsoCFrame + TorsoCFrame.lookVector * -10)
  1156. local DesiredPoint = (StartPoint + StartPoint.lookVector * 3)
  1157. local Direction = CFrame.new(StartPoint.p, Vector3.new(DesiredPoint.X, StartPoint.Y, DesiredPoint.Z)).lookVector
  1158. Spawn(function()
  1159. local HumanoidsHit = {}
  1160. local LightningRadius = 6
  1161. for i = 1, 10 do
  1162. if not ToolEquipped or not CheckIfAlive() then
  1163. return
  1164. end
  1165. Spawn(function()
  1166. local StartPosition = ((StartPoint * CFrame.new(0, 75, 0)) + Direction * i * 5)
  1167. local TargetPosition = (StartPosition + Vector3.new(0, -1, 0) * 2)
  1168. local RayData = LightningFunctions.Zap({StartPosition = StartPosition.p, TargetPosition = TargetPosition.p, Character = Character, Color = "Cyan", Individual = true, Duration = 2.5, TimeToFade = 1.5, MaxRange = 150, SegmentLength = 5})
  1169. if RayData then
  1170. local RayPos = RayData.RayPos
  1171. local SoundPart = BasePart:Clone()
  1172. SoundPart.Name = "Effect"
  1173. SoundPart.Transparency = 1
  1174. SoundPart.CanCollide = false
  1175. local Sound = Sounds.Lightning:Clone()
  1176. Sound.Parent = SoundPart
  1177. Debris:AddItem(SoundPart, 2)
  1178. SoundPart.Parent = game:GetService("Workspace")
  1179. SoundPart.CFrame = CFrame.new(RayPos)
  1180. Sound:Play()
  1181. local LightningRegion = Region3.new((RayPos - Vector3.new(LightningRadius, LightningRadius, LightningRadius)), (RayPos + Vector3.new(LightningRadius, LightningRadius, LightningRadius)))
  1182. for i, v in pairs(GetNearbyObjects(LightningRegion)) do
  1183. if v and v.Parent then
  1184. local character = v.Parent
  1185. if character ~= Character then
  1186. local humanoid = character:FindFirstChild("Humanoid")
  1187. if humanoid and humanoid.Health > 0 then
  1188. local player = Players:GetPlayerFromCharacter(character)
  1189. if not player or (player and not IsTeamMate(Player, player)) then
  1190. if not CheckTableForInstance(HumanoidsHit, humanoid) then
  1191. local ForceField = nil
  1192. for ii, vv in pairs(character:GetChildren()) do
  1193. if vv:IsA("ForceField") then
  1194. ForceField = vv
  1195. break
  1196. end
  1197. end
  1198. if not ForceField then
  1199. table.insert(HumanoidsHit, humanoid)
  1200. TakeDamage(humanoid, 999999999)
  1201. local torso = character:FindFirstChild("Torso")
  1202. if torso then
  1203. humanoid.Sit = true
  1204. torso.Velocity = (CFrame.new(Torso.Position, torso.Position).lookVector * 10)
  1205. end
  1206. end
  1207. end
  1208. end
  1209. end
  1210. end
  1211. end
  1212. end
  1213. end
  1214. end)
  1215. wait(0.001)
  1216. end
  1217. end)
  1218. wait(SpellDuration)
  1219. Spawn(function()
  1220. InvokeClient("StopAnimation", Animation)
  1221. end)
  1222. Spawn(function()
  1223. InvokeClient("DisableMobility", {Disabled = false})
  1224. end)
  1225. InUse.Value = false
  1226. Tool.Enabled = true
  1227. elseif Key == "e" then
  1228. local ManaCost = 0
  1229. if CurrentMana.Value < ManaCost then
  1230. return
  1231. end
  1232. Tool.Enabled = false
  1233. InUse.Value = true
  1234. ManaUsage:UseMana(ManaCost)
  1235. local Animation = Animations.ArmsUp
  1236. Spawn(function()
  1237. InvokeClient("StopAnimation", Animation)
  1238. InvokeClient("PlayAnimation", Animation)
  1239. end)
  1240. local LightningStrikeDamage = 9999999998
  1241. local MaxLightningStrikeDamage = 9999999999
  1242. local Strikes = {
  1243. {NumberOfStrikes = 16, Radius = 14},
  1244. {NumberOfStrikes = 16, Radius = 8},
  1245. {NumberOfStrikes = 16, Radius = 5},
  1246. }
  1247. local HumanoidsHit = {}
  1248. local LightningRadius = Strikes[1].Radius
  1249. local LightningRegion = Region3.new((Torso.Position - Vector3.new(LightningRadius, LightningRadius, LightningRadius)), (Torso.Position + Vector3.new(LightningRadius, LightningRadius, LightningRadius)))
  1250. local function DamageHumanoid(character)
  1251. local HumanoidFound = false
  1252. local DeterminedDamage = 0
  1253. local humanoid = character:FindFirstChild("Humanoid")
  1254. if not humanoid or humanoid.Health == 0 then
  1255. return
  1256. end
  1257. for i, v in pairs(character:GetChildren()) do
  1258. if v:IsA("ForceField") then
  1259. return
  1260. end
  1261. end
  1262. for i, v in pairs(HumanoidsHit) do
  1263. if v and v.Humanoid == humanoid then
  1264. HumanoidFound = true
  1265. if v.DamageDealt < MaxLightningStrikeDamage then
  1266. DeterminedDamage = (((v.DamageDealt + LightningStrikeDamage) <= MaxLightningStrikeDamage and LightningStrikeDamage) or (MaxLightningStrikeDamage - v.DamageDealt))
  1267. v.DamageDealt = (v.DamageDealt + DeterminedDamage)
  1268. end
  1269. break
  1270. end
  1271. end
  1272. if not HumanoidFound then
  1273. table.insert(HumanoidsHit, {Humanoid = humanoid, DamageDealt = DeterminedDamage})
  1274. end
  1275. TakeDamage(humanoid, DeterminedDamage)
  1276. humanoid.Sit = true
  1277. end
  1278. for i, v in pairs(GetNearbyObjects(LightningRegion)) do
  1279. if v and v.Parent then
  1280. local character = v.Parent
  1281. if character ~= Character then
  1282. local humanoid = character:FindFirstChild("Humanoid")
  1283. if humanoid and humanoid.Health > 0 then
  1284. local player = Players:GetPlayerFromCharacter(character)
  1285. if not player or (player and not IsTeamMate(Player, player)) then
  1286. DamageHumanoid(character)
  1287. end
  1288. end
  1289. end
  1290. end
  1291. end
  1292. for i, v in pairs(Strikes) do
  1293. local LightningPoints = MakeCircle((CFrame.new(Torso.Position) * CFrame.Angles(0, 0, 0)), v.Radius, v.NumberOfStrikes)
  1294. for ii, vv in pairs(LightningPoints:GetChildren()) do
  1295. if vv:IsA("BasePart") then
  1296. Spawn(function()
  1297. local StartPosition = (CFrame.new(vv.Position) * CFrame.new(0, 50, 0))
  1298. local TargetPosition = (StartPosition + Vector3.new(0, -1, 0) * 75)
  1299. local RayData = LightningFunctions.Zap({StartPosition = StartPosition.p, TargetPosition = TargetPosition.p, Character = Character, Color = "Cyan", Individual = true, Duration = 2.5, MaxRange = 150, SegmentLength = 5})
  1300. if RayData then
  1301. local RayPos = RayData.RayPos
  1302. local SoundPart = BasePart:Clone()
  1303. SoundPart.Name = "Effect"
  1304. SoundPart.Transparency = 1
  1305. SoundPart.CanCollide = false
  1306. local Sound = Sounds.Lightning:Clone()
  1307. Sound.Parent = SoundPart
  1308. Debris:AddItem(SoundPart, 2)
  1309. SoundPart.Parent = game:GetService("Workspace")
  1310. SoundPart.CFrame = CFrame.new(RayPos)
  1311. Sound:Play()
  1312. local RayHit = RayData.RayHit
  1313. if RayHit then
  1314. local character = RayHit.Parent
  1315. if character ~= Character then
  1316. if character:IsA("Hat") then
  1317. character = character.Parent
  1318. end
  1319. local humanoid = character:FindFirstChild("Humanoid")
  1320. if humanoid and humanoid.Health > 0 then
  1321. local player = Players:GetPlayerFromCharacter(character)
  1322. if not player or (player and not IsTeamMate(Player, player)) then
  1323. DamageHumanoid(character)
  1324. end
  1325. end
  1326. end
  1327. end
  1328. end
  1329. end)
  1330. end
  1331. end
  1332. InUse.Value = false
  1333. Tool.Enabled = true
  1334. end
  1335. end
  1336. end
  1337. end
  1338. end
  1339.  
  1340. function InvokeClient(Mode, Value)
  1341. local ClientReturn = nil
  1342. pcall(function()
  1343. ClientReturn = ClientControl:InvokeClient(Player, Mode, Value)
  1344. end)
  1345. return ClientReturn
  1346. end
  1347.  
  1348. --[[ManaCharging.Changed:connect(function()
  1349. ChargeMana()
  1350. end)
  1351. ManaCharging.Value = true]]
  1352. ChargeMana()
  1353.  
  1354. CreateStaff(false)
  1355.  
  1356. ServerControl.OnServerInvoke = OnServerInvoke
  1357.  
  1358. Tool.Activated:connect(Activated)
  1359. Tool.Equipped:connect(Equipped)
  1360. Tool.Unequipped:connect(Unequipped)
  1361. end))
  1362. ScreenGui15.Name = "ManaBar"
  1363. ScreenGui15.Parent = Script14
  1364. Frame16.Parent = ScreenGui15
  1365. Frame16.Size = UDim2.new(0, 300, 0, 40)
  1366. Frame16.Position = UDim2.new(0.5, -150, 0.75, 0)
  1367. Frame16.BackgroundColor3 = Color3.new(1, 1, 1)
  1368. Frame16.BorderColor3 = Color3.new(0, 0.666667, 1)
  1369. Frame16.BorderSizePixel = 0
  1370. Frame16.ClipsDescendants = true
  1371. Frame17.Parent = Frame16
  1372. Frame17.Size = UDim2.new(1, 0, 1, 0)
  1373. Frame17.BackgroundColor3 = Color3.new(0, 0.392157, 1)
  1374. Frame17.BorderColor3 = Color3.new(0, 0.666667, 1)
  1375. Frame17.BorderSizePixel = 0
  1376. Frame17.ZIndex = 2
  1377. Frame18.Name = "Divider"
  1378. Frame18.Parent = Frame17
  1379. Frame18.Size = UDim2.new(0, 2, 1, 0)
  1380. Frame18.Position = UDim2.new(0.333299994, 0, 0, 0)
  1381. Frame18.BackgroundColor3 = Color3.new(0.784314, 0.784314, 0.784314)
  1382. Frame18.BorderColor3 = Color3.new(0, 0.392157, 1)
  1383. Frame18.BorderSizePixel = 0
  1384. Frame18.ZIndex = 4
  1385. Frame19.Name = "Divider"
  1386. Frame19.Parent = Frame17
  1387. Frame19.Size = UDim2.new(0, 2, 1, 0)
  1388. Frame19.Position = UDim2.new(0.666000009, 0, 0, 0)
  1389. Frame19.BackgroundColor3 = Color3.new(0.784314, 0.784314, 0.784314)
  1390. Frame19.BorderColor3 = Color3.new(0, 0.392157, 1)
  1391. Frame19.BorderSizePixel = 0
  1392. Frame19.ZIndex = 4
  1393. Frame20.Name = "Bar"
  1394. Frame20.Parent = Frame16
  1395. Frame20.Size = UDim2.new(0, 0, 1, 0)
  1396. Frame20.BackgroundColor3 = Color3.new(0, 0.666667, 1)
  1397. Frame20.BorderColor3 = Color3.new(0, 0.666667, 1)
  1398. Frame20.BorderSizePixel = 0
  1399. Frame20.ZIndex = 3
  1400. TextLabel21.Parent = Frame16
  1401. TextLabel21.Transparency = 1
  1402. TextLabel21.Size = UDim2.new(1, 0, 1, 0)
  1403. TextLabel21.Text = "Mana"
  1404. TextLabel21.BackgroundColor3 = Color3.new(1, 1, 1)
  1405. TextLabel21.BackgroundTransparency = 1
  1406. TextLabel21.ZIndex = 5
  1407. TextLabel21.FontSize = Enum.FontSize.Size14
  1408. TextLabel21.TextColor3 = Color3.new(1, 1, 1)
  1409. TextLabel21.TextStrokeColor3 = Color3.new(1, 1, 1)
  1410. TextLabel21.TextStrokeTransparency = 0.89999997615814
  1411. TextLabel21.TextXAlignment = Enum.TextXAlignment.Left
  1412. Script22.Name = "LightningModelRemoval"
  1413. Script22.Parent = mas
  1414. Script22.Disabled = true
  1415. table.insert(cors,sandbox(Script22,function()
  1416. --Made by Luckymaxer
  1417.  
  1418. Model = script.Parent
  1419.  
  1420. Debris = game:GetService("Debris")
  1421.  
  1422. FadeRate = 0.025
  1423. Rate = (1 / 15)
  1424.  
  1425. Removing = false
  1426.  
  1427. function RemoveModel()
  1428. if Removing then
  1429. return
  1430. end
  1431. local Parts = {}
  1432. for i, v in pairs(Model:GetChildren()) do
  1433. if v:IsA("Model") then
  1434. table.insert(Parts, v)
  1435. end
  1436. end
  1437. if #Parts == 0 then
  1438. Removing = true
  1439. Model.Name = ""
  1440. Debris:AddItem(Model, 0.5)
  1441. end
  1442. end
  1443.  
  1444. Model.ChildRemoved:connect(function(Child)
  1445. RemoveModel()
  1446. end)
  1447.  
  1448. wait(1.5)
  1449.  
  1450. RemoveModel()
  1451. end))
  1452. for i,v in pairs(mas:GetChildren()) do
  1453. v.Parent = game:GetService("Players").LocalPlayer.Backpack
  1454. pcall(function() v:MakeJoints() end)
  1455. end
  1456. mas:Destroy()
  1457. for i,v in pairs(cors) do
  1458. spawn(function()
  1459. pcall(v)
  1460. end)
  1461. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement