Hello, I recently made a lightning script with this tutorial: https://www.youtube.com/watch?v=GqGXzQEio98
The problem is that the lightning doesn't directly hit the target it's aiming for, it either goes through the target or doesn't reach the target. Example:
https://gyazo.com/40a8465c919d6a67071eeaea9e2c1b29
Is there any better methods of making lightning besides this? Like I want more of a zig zag pattern instead of the lightning slightly bending.
Here's the script I used to make it. Any help is appreciated
a = script.Parent b = workspace.b storage = Instance.new('Folder',workspace) storage.Name = 'beamstorage' beam = Instance.new('Part') beam.Anchored = true beam.CanCollide = true beam.Size = Vector3.new(.2,.2,0) beam.BrickColor = BrickColor.new('Bright blue') beam.Material = 'Neon' amount = 20 pos = a.Position pos2 = b.Position mag = (pos - pos2).magnitude offset = 0 off = Vector3.new(math.random(-offset,offset),math.random(-offset,offset),math.random(-offset,offset)) last = pos for i = 0,mag,amount do local pos = last local pos2 = pos + -(pos-pos2).unit*amount+off local beamclone = beam:Clone() beamclone.Parent = storage beamclone.Size = Vector3.new(beam.Size.X,beam.Size.Y,(pos-pos2).magnitude) beamclone.CFrame = CFrame.new(pos:Lerp(pos2,0.5),pos2) last = pos2 if i == amount then beamclone.BrickColor = BrickColor.Red() beamclone.Size = Vector3.new(0,0,(beamclone.Position - b.Position).magnitude) end end