I am trying to achieve an effect of a lighting coming from the middle and continuing until it touches an object and explodes at the tip. I made a sketch that may help out
I already made a script but it doesn’t do what I want it to do. This is it:
while wait(tonumber(script.Wait.Value)) do
local shootPos = script.Parent.CFrame*CFrame.fromEulerAnglesXYZ(math.rad(math.random(-180,180)),math.rad(math.random(-180,180)),math.rad(math.random(-180,180)))
for i = 1, 25 do
local shootPart = Instance.new("Part", workspace)
shootPart.Color = script.Color.Value
shootPart.Anchored = true
shootPart.CanCollide = false
shootPart.Size = Vector3.new(0.5,5,0.5)
shootPart.Transparency = 0.5
shootPart.Material = Enum.Material.Neon
local r1 = math.rad(math.random(-50,50))
local r2 = math.rad(math.random(-50,50))
local r3 = math.rad(math.random(-50,50))
shootPart.CFrame = shootPos*CFrame.fromEulerAnglesXYZ(r1,r2,r3)*CFrame.new(0,2.5,0)
shootPos = shootPart.CFrame*CFrame.new(0,2.5,0)*CFrame.fromEulerAnglesXYZ(-r1,-r2,-r3)
game:GetService("Debris"):AddItem(shootPart,0.5)
game:GetService("TweenService"):Create(shootPart,TweenInfo.new(0.5,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut,0,false,0),{Transparency = 1, Size = Vector3.new(0,5,0)}):Play()
end
end
I may know how to do it and stuff but I don’t really know math for it so I hope somebody could help out.