this is the script and were you see >> everything in here<< is what i added to it and then it stopped working. can you tell me how i can add that part so this works again.
local sp = script.Parent
local coil = sp.SecondaryCoil
local toroid = sp.Toroid
local segmentlength = 5
local varience = 5
local timetofade=.8
function raycast(spos,vec,currentdist)
local hit2,pos2=game.Workspace:FindPartOnRay(Ray.new(spos+(vec*.01),vec*currentdist),sp)
if hit2~=nil and pos2 then
if hit2.Transparency>=.5 or hit2.Name=="Handle" then
local currentdist=currentdist-(pos2-spos).magnitude
return raycast(pos2,vec,currentdist)
end
end
return hit2,pos2
end
function zap(targetpos)
if targetpos then
local m = Instance.new("Model")
m.Name = "Lightning"
local lastpos=toroid.Position
local totalsegments=math.ceil(25/segmentlength)
local direction=(targetpos-toroid.Position).unit
local struck=false
for i=1,totalsegments do
if not struck then
local entropy=Vector3.new(varience*((math.random()*2)-3),varience*((math.random()*2)-3),varience*((math.random()*2)-3))
local newpos=toroid.Position+(direction*(60*(i/totalsegments)))+entropy
local hit,endpos=raycast(lastpos,(newpos-lastpos).unit,(lastpos-newpos).magnitude)
local l=Instance.new("Part")
l.CanCollide=false
l.Anchored=true
l.Material=("Neon")
l.BrickColor=BrickColor.new("Toothpaste")
l.formFactor="Custom"
l.Size=Vector3.new(.2,.2,.2)
>>l.Instance.new("Explosion")
l.Explosion.BlastPressure=1000
l.Explosion.BlastRadius=4<<
l.CFrame=CFrame.new(lastpos,endpos)*CFrame.Angles(math.pi/2,0,0)*CFrame.new(0,-(lastpos-endpos).magnitude/2,0)
local mesh=Instance.new("CylinderMesh")
mesh.Scale=Vector3.new(.35,(lastpos-endpos).magnitude,.35)*5
mesh.Parent=l
delay(0,function()
for i=1,timetofade/(.1) do
wait(.1)
l.Transparency=i/(timetofade/(.1))
end
end)
l.Parent=m
if hit and hit.Parent~=nil then
struck=true
local h=hit.Parent:FindFirstChild("Humanoid")
if h then
h:TakeDamage(1)
end
end
toroid.Fire:Play()
lastpos=endpos
end
end
m.Parent=game.Workspace
game:GetService("Debris"):AddItem(m,1.5)
end
end
function findNearestTorso(pos)
local list = game.Workspace:children()
local torso = nil
local dist = 1
local temp = nil
local human = nil
local temp2 = nil
for x = 1, #list do
temp2 = list[x]
if (temp2.className == "Model") and (temp2 ~= script.Parent) then
temp = temp2:findFirstChild("Torso")
human = temp2:findFirstChild("Humanoid")
if (temp ~= nil) and (human ~= nil) and (human.Health > 0) then
if (temp.Position - pos).magnitude < dist then
torso = temp
dist = (temp.Position - pos).magnitude
end
end
end
end
return torso
end
while true do
local prob = math.random(1, 3)
local gg = findNearestTorso(toroid.Position)
if gg then
for i = 0, prob do
zap(gg.Position)
end
else
for i = 0, prob do
local xen = math.random(-600,600)
local yen = math.random(10,100)
local zen = math.random(-600,600)
local plrob = math.random(1,2)
if plrob == 1 then zap(Vector3.new(toroid.Position.X+xen,yen,toroid.Position.Z+zen)) end
end
end
wait(1)
end |