Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --// Script By RoastedPresident2000
- game:GetService('ReplicatedStorage').ElectricZap.OnServerEvent:Connect(function(plr,MOUSE)
- local char = plr.Character
- local rarm = char:WaitForChild("RightHand")
- local larm = char:WaitForChild("LeftHand")
- local hed = char:WaitForChild("Head")
- local torso = char:WaitForChild("UpperTorso")
- local root = char:WaitForChild("HumanoidRootPart")
- local hum = char:FindFirstChildOfClass("Humanoid")
- local debris = game:GetService("Debris")
- local run = game:GetService("RunService")
- local rs = run.Heartbeat
- local DebrisModel = Instance.new("Model",char)
- DebrisModel.Name ="Debris"
- --//Turn Character To Position
- root.CFrame = CFrame.new(root.Position,Vector3.new(MOUSE.x,root.Position.Y,MOUSE.z))
- local function findAllNearestTorso(pos,dist)
- local list = workspace:children()
- local torso ={}
- local temp = nil
- local human = nil
- local temp2 = nil
- for x = 1,#list do
- temp2 = list[x]
- if (temp2.className =="Model") and (temp2 ~= char) then
- temp = temp2:findFirstChild("UpperTorso")
- human = temp2:findFirstChildOfClass("Humanoid")
- if (temp ~= nil) and (human ~= nil) and (human.Health > 0) then
- if (temp.Position - pos).magnitude < dist then
- table.insert(torso,temp)
- dist =(temp.Position - pos).magnitude
- end
- end
- end
- end
- return torso
- end
- function sound(id,position,vol,pitch,start,finish)
- coroutine.resume(coroutine.create(function()
- local part = Instance.new("Part",workspace)
- part.Position = position
- part.Size = Vector3.new(0,0,0)
- part.CanCollide = false
- part.Transparency = 1
- local sound = Instance.new("Sound",part)
- sound.SoundId = "rbxassetid://"..id
- repeat rs:wait() until sound.IsLoaded
- if vol ~= nil then
- sound.Volume = vol
- end
- if pitch ~= nil then
- sound.PlaybackSpeed = pitch
- end
- if start ~= nil then
- sound.TimePosition = start
- end
- if finish ~= nil then
- debris:AddItem(part,finish-start)
- else
- debris:AddItem(part,sound.TimeLength)
- end
- sound:Play()
- return sound
- end))
- end
- local function computeDirection(vec)
- local lenSquared = vec.magnitude * vec.magnitude
- local invSqrt = 1 / math.sqrt(lenSquared)
- return Vector3.new(vec.x * invSqrt, vec.y * invSqrt, vec.z * invSqrt)
- end
- local function Effect(mesh,size,transparency,material,color,position,rotation,positionchange,sizechange,rotationchange,transparencychange,acceleration)
- local part = Instance.new("Part",DebrisModel)
- part.Anchored = true
- part.CanCollide = false
- part.Size = Vector3.new(1,1,1)
- part.Transparency = transparency
- part.Material = material
- part.Color = color
- part.CFrame = CFrame.new(position)*CFrame.Angles(math.rad(rotation.X),math.rad(rotation.Y),math.rad(rotation.Z))
- local partmesh = Instance.new("SpecialMesh",part)
- if tonumber(mesh)== nil then partmesh.MeshType = mesh else partmesh.MeshId ="rbxassetid://"..mesh end
- partmesh.Scale = size
- local pvalue = Instance.new("Vector3Value",part)
- pvalue.Name ="Position"
- pvalue.Value = positionchange
- local svalue = Instance.new("Vector3Value",part)
- svalue.Name ="Size"
- svalue.Value = sizechange
- local rvalue = Instance.new("Vector3Value",part)
- rvalue.Name ="Rotation"
- rvalue.Value = rotationchange
- local tvalue = Instance.new("NumberValue",part)
- tvalue.Name ="Transparency"
- tvalue.Value = transparencychange
- local avalue = Instance.new("NumberValue",part)
- avalue.Name ="Acceleration"
- avalue.Value = acceleration
- part.Name ="EFFECT"
- return part
- end
- local function Lightning(Part0,Part1,Times,Offset,Color,Thickness,Trans)
- local magz =(Part0 - Part1).magnitude
- local curpos = Part0
- local trz ={-Offset,Offset}
- for i=1,Times do
- local li = Instance.new("Part", DebrisModel)
- li.TopSurface =0
- li.Material = Enum.Material.Neon
- li.BottomSurface = 0
- li.Anchored = true
- li.Locked = true
- li.Transparency = Trans or 0.4
- li.Color = Color
- li.Shape = Enum.PartType.Cylinder
- li.formFactor ="Custom"
- li.CanCollide = false
- li.Size = Vector3.new(Thickness,Thickness,magz/Times)
- --//This Adds the Particle To the Lightning
- --local LightningParticle = script.LightningParticle:Clone()
- --LightningParticle.Parent = li
- local lim = Instance.new("BlockMesh",li)
- local Offzet = Vector3.new(trz[math.random(1,2)],trz[math.random(1,2)],trz[math.random(1,2)])
- local trolpos = CFrame.new(curpos,Part1)*CFrame.new(0,0,magz/Times).p+Offzet
- if Times == i then
- local magz2 =(curpos - Part1).magnitude
- li.Size = Vector3.new(Thickness,Thickness,magz2)
- li.CFrame = CFrame.new(curpos,Part1)*CFrame.new(0,0,-magz2/2)
- else
- li.CFrame = CFrame.new(curpos,trolpos)*CFrame.new(0,0,magz/Times/2)
- end
- curpos = li.CFrame*CFrame.new(0,0,magz/Times/2).p
- li.Name ="LIGHTNING"
- end
- end
- local Position = rarm.Position-rarm.CFrame.upVector
- local Position1 = larm.Position-rarm.CFrame.upVector
- local Target = MOUSE.p
- local direction = Target - Position
- local direction = computeDirection(direction)
- local ray = Ray.new(Position,(Target-Position).unit*1048)
- local part, endPoint = workspace:FindPartOnRay(ray, char)
- --//This Deals Damage
- --for i,v in pairs(findAllNearestTorso(endPoint,30)) do
- -- v.Parent:FindFirstChildOfClass("Humanoid"):TakeDamage(v.Parent:FindFirstChildOfClass("Humanoid").MaxHealth/math.random(10,12))
- --end
- sound(1202656211,root.Position,10,math.random(90,110)/100)
- --//This creates the lightning
- for i=1,10 do rs:Wait()
- Lightning(rarm.Position-rarm.CFrame.upVector,endPoint, math.random(5,10), 2, Color3.fromRGB(math.random(100,150),160,255),.5,.05)
- end
- if char then
- local LightningGroup = DebrisModel:GetChildren()
- repeat rs:Wait()
- for i=1,#LightningGroup do
- if LightningGroup[i]:FindFirstChildOfClass("BlockMesh").Scale.X > 0 then
- LightningGroup[i]:FindFirstChildOfClass("BlockMesh").Scale = LightningGroup[i]:FindFirstChildOfClass("BlockMesh").Scale - Vector3.new(0.1,0.1,0)
- elseif LightningGroup[i]:FindFirstChildOfClass("BlockMesh").Scale.X <= 0 then
- LightningGroup[i]:Destroy()
- end
- end
- until DebrisModel:FindFirstChild('LIGHTNING') == nil or DebrisModel == nil
- DebrisModel:Destroy()
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement