local A=os.clock local function n(A,n,M,N,y,S,Q)return math.clamp(M/(2*N)-math.abs(((A-y*n)+.5*M)/N),S,Q)end local function M(A,n,M,N,y)return N+(y-N)*(math.noise(A,n,M)+.5)end local function N(A,n,M,N,y)return((A*(1-y)^3+((n*3)*y)*(1-y)^2)+((M*3)*(1-y))*y^2)+N*y^3 end local y=Instance.new("\080\097\114\116")y.TopSurface,y.BottomSurface=0,0 y.Anchored,y.CanCollide=true,false y.Shape="\067\121\108\105\110\100\101\114"y.Name="\066\111\108\116\080\097\114\116"y.CanTouch=false y.CastShadow=false y.CanQuery=false y.Material=Enum.Material.Neon y.Color=Color3.new(1,1,1)y.Transparency=1 local S=Random.new()local Q=(CFrame.lookAt(Vector3.new(),Vector3.new(1,0,0))):inverse()local p={}local z={}z.__index=z


local clock = os.clock






local function DiscretePulse(input, s, k, f, t, min, max) --input should be between 0 and 1. See https://www.desmos.com/calculator/hg5h4fpfim for demonstration.
	return math.clamp( (k)/(2*f) - math.abs( (input - t*s + 0.5*(k)) / (f) ), min, max )
end

local function NoiseBetween(x, y, z, min, max)
	return min + (max - min)*(math.noise(x, y, z) + 0.5)
end

local function CubicBezier(p0, p1, p2, p3, t)
	return p0*(1 - t)^3 + p1*3*t*(1 - t)^2 + p2*3*(1 - t)*t^2 + p3*t^3
end

local BoltPart = Instance.new("Part")
BoltPart.TopSurface, BoltPart.BottomSurface = 0, 0
BoltPart.Anchored, BoltPart.CanCollide = true, false
BoltPart.Shape = "Cylinder"
BoltPart.Name = "BoltPart"
BoltPart.CanTouch = false
BoltPart.CastShadow = false
BoltPart.CanQuery = false
BoltPart.Material = Enum.Material.Neon
BoltPart.Color = Color3.new(1, 1, 1)
BoltPart.Transparency = 1

local rng = Random.new()
local xInverse = CFrame.lookAt(Vector3.new(), Vector3.new(1, 0, 0)):inverse()

local ActiveBranches = {}

local LightningBolt = {}
LightningBolt.__index = LightningBolt
