Title says it all, I can’t rewrite everything because it’s too long. (Nobody would like to rewrite lots of code, right?)
Code
The main function:
function lightningmodule.Create(point1, point2, color, isStraightLine)
if typeof(point1) == "Instance" and typeof(point2) == "Instance" then
point2.Orientation = point1.Orientation
local timesToGetLightningStrike = math.random(3, 5)
local tableOfLerps = {}
for i = 1, timesToGetLightningStrike do
local lerpAlpha = random:NextNumber(0, 0.9)
local lerpCFrame = point1.CFrame:Lerp(point2.CFrame, lerpAlpha)
if #tableOfLerps ~= 0 then
local lastNumTable = tableOfLerps[#tableOfLerps]
local lastnum = lastNumTable[2]
if lerpAlpha <= lastnum and (math.abs(lerpAlpha - lastnum) >= 0.2 or (math.abs(lastnum - lerpAlpha) >= 0.2)) then
repeat
lerpAlpha = random:NextNumber()
lerpCFrame = point1.CFrame:Lerp(point2.CFrame, lerpAlpha)
until not (lerpAlpha <= lastnum) and not (math.abs(lerpAlpha - lastnum) >= 0.2 or (math.abs(lastnum - lerpAlpha) >= 0.2))
end
local lastTable = {lerpCFrame, lerpAlpha}
table.insert(tableOfLerps, lastTable)
else
local lastTable = {lerpCFrame, lerpAlpha}
table.insert(tableOfLerps, lastTable)
end
end
local folderOfPoints = Instance.new("Folder")
folderOfPoints.Parent = game.Workspace
folderOfPoints.Name = "LightningPoints"
for i, v in ipairs(tableOfLerps) do
lightningPointCreate(1, v[1], color, isStraightLine, folderOfPoints)
end
elseif typeof(point1) == "Vector3" and typeof(point2) == "Vector3" then
error("Cannot use Vector3.new(" .. point1.X .. ", " .. point1.Y .. ", " .. point1.Z .. ") and Vector3.new(" .. point2.X .. ", " .. point2.Y .. ", " .. point2.Z .. ") as points.")
else
error("Cannot use " .. point1 .. " and " .. point2 .. " as points.")
end
if typeof(color) ~= "Color3" then
error("Attempt to use " .. color .. " as a Color3")
end
end
The function lightningPointCreate():
local function lightningPointCreate(amountOfPoints, cframeAmount, color, isStraight, parent)
if color == nil then
color = defaultColor
if isStraight == nil then
isStraight = true
end
end
if typeof(amountOfPoints) == "number" and amountOfPoints == math.floor(amountOfPoints) then
for i = 1, amountOfPoints do
local point = Instance.new("Part")
point.Size = Vector3.new(1, 1, 1)
point.Anchored = true
point.CFrame = cframeAmount
point.Color = color
point.Transparency = 0.75
point.CanCollide = false
point.Parent = parent
if isStraight == false then
local scrip = movePointScript:Clone()
scrip.Disabled = false
scrip.Parent = point
end
end
else
error("Attempt to use" .. amountOfPoints .. " as an integer")
end
end
I know it’s possible, I just don’t know how.