How to Weld Each Part of it while keeping the position?

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

weld the lightning parts to a “base” part, like the humanoidrootpart, do some simple cframe maths to create it on the correct position

I don’t really know what you are going for but this seems really nice since it’s some sort of lightning

What do you mean by simple CFrame math

creating a simple formula for the lightning to look like lightning =w=
but FROM the cframe of the “base”

1 Like

Is it possible for a example i’m sorry if i’m asking too much :C

simple example -w-
afbeelding
afbeelding
afbeelding

1 Like