So I have made a lightning script which basically makes a straight path between 2 points and segments it and gives the segments offset;
what I want to do is make this straight path curved
This Is what I have made so far-
local module = {}
module.Lit = function(startpos,endpos,segments)
local points = {}
local model = Instance.new("Model")
model.Parent = workspace
model.Name = "Modal da debris"
for i=0,segments do
local offset
--important part
local position = startpos + (endpos - startpos).Unit *i* (endpos -startpos).Magnitude/segments
--offset thingie
if i == 0 or i == segments then
offset = Vector3.new(0,0,0)
else
offset = Vector3.new( math.random(-2,-2),math.random(-2,2),math.random(-2,2) )
end
local i2
if i ==0 then
i2 = 1
else
i2 = i
end
points[i2] = position + offset
local lightning = script.Part:Clone()
lightning.Position = position + offset
lightning.Parent = model
lightning.Name = "seg"..tostring(i)
end
--you can ignore this until and unless u wanna know how i connect the segments with the beams
for i =1, #points do
if points[i] ~= nil then
local beam = script.Beam:Clone()
local attach = Instance.new("Attachment")
attach.Parent = model["seg"..tostring(i-1)]
local attach1 = Instance.new("Attachment")
attach1.Parent = model["seg"..tostring(i)]
beam.Attachment0 = attach
beam.Attachment1 = attach1
beam.Parent = model
end
end
return model
end
return module
I am just trying to make a curved path with a given radius and center and maybe 2 endpoints