I want to weld it to keep make it look smooth and so this what happens
local module = {}
module.createLighting = function(StartInstance, StartPos, endPos, segments)
local points = {}
local Model = Instance.new("Model")
Model.Name = "Lightning"
Model.Parent = game.Workspace
for i = 0, segments do
local offset = Vector3.new(math.random(-1,1),math.random(-1,1),math.random(-1,1))
local position = StartPos + (endPos - StartPos).Unit * i * (endPos - StartPos).Magnitude / segments
if i == 0 or i == segments then
offset = Vector3.new(0,0,0)
end
points[#points + 1] = position + offset
end
for i = 1, #points do
if points[i + 1] ~= nil then
local prevLightling
local Lightling = script.Part:Clone()
Lightling.Size = Vector3.new(0.1,0.1,(points[i] - points[i + 1]).Magnitude)
Lightling.Name = "Part"..i..""
Lightling.CFrame = CFrame.new((points[i] + points[i + 1]) / 2, points[i + 1])
Lightling.Parent = Model
end
end
return Model
end
return module
I run the module in a local script just for no dely