I need help with a Lightning Arc

So I’ve been trying to make a lightning arc by filling blocks between 2 points and randomizing positions, but when I do this, it makes a scattered and non-nonsensical effect. How do I make the parts connect to the ends of eachother while still being correct?

This is the code:

	local magnitude = (workspace.TheN00bDeveloperMoves["Ib" .. num-1].Position - workspace.TheN00bDeveloperMoves["Ib" .. num].Position).magnitude
			local part = Instance.new("Part", workspace.TheN00bDeveloperMoves)
			part.Size = Vector3.new(.25,.25,magnitude)
			part.Anchored = true
			part.CanCollide = false
			part.Name = "l" .. num
			part.Material = Enum.Material.Neon
			part.BrickColor = BrickColor.new("Toothpaste")
			part.CFrame = CFrame.new(
				workspace.TheN00bDeveloperMoves["l" .. num-1].Position:Lerp(workspace.TheN00bDeveloperMoves["Ib" .. num].Position, 0.5),
				workspace.TheN00bDeveloperMoves["Ib" .. num].Position + Vector3.new(math.random(-1,1),math.random(-1,1),math.random(-1,1))
			)
			num = num + 1

**the “l” in the code is the lightning bolts and the Ib is the blocks in between the 2 parts

1 Like

I recommend looking at this cool electric arc effects thing that buildthomas made

I don’t really understand a single thing in his coding so I’d prefer an example or excerpt

The Usage section of the post is pretty self explanatory.

Pulled directly from the post, this shows exactly how to link the two parts with lightning. There also seems to be some pretty neat property modifiers that you can tinker with aswell.

local Arc = require(game.(...).Arc)

-- Make an arc between two static points with default colors:
local arc1 = Arc.new(
    Vector3.new(10, 10, 0),
    Vector3.new(-10, 10, 0)
)

-- Make a dynamic arc linked between two (moving) attachments:
local arc2 = Arc.link(
    workspace.ArcStart.Attachment,
    workspace.ArcEnd.Attachment
)
1 Like

If you could, can you show me an example of it being in use(not in the other person’s thread) but in your own style? I’d like to see how it can be used because the snip bit you send in your post has little to no effect

Again, I don’t see how this isn’t something you can’t easily figure out yourself? The usage is pretty self explanatory. Even the default arc settings provide a pretty cool result.

local arc = Arc.new(
	workspace.p1.Position,
	workspace.p2.Position
)

https://gyazo.com/91e530ec8d698e949914194a5c26cb01

I spent maybe the whole of 30 seconds messing the other properties to create an effect that looks something like what you were going for. You can very easily do the same to achieve the effect you want.

local Arc = require(game.ReplicatedStorage.Arc)

local arc = Arc.new(
	workspace.p1.Position,       -- position1
	workspace.p2.Position,       -- position2
	Color3.fromRGB(0, 255, 255), -- main color (toothpaste)
	Color3.fromRGB(0, 255, 255), -- second color (same as main)
	1,                           -- number of arcs
	5                            -- thickness
)

https://gyazo.com/582021624d7ced940eadf39d81785715

I will admit I was slightly confused with using the module at first because I didn’t realize it was client sided (which is actually for the best as it won’t strain the server). I put this code in a LocalScript in StarterCharacterScripts.

Okay, but I don’t want a local client sided script

From the Electric Arcs Effect Thread:
"Please note that this is still somewhat on the performance-heavy side and may be an overkill kind of implementation for such an electricity effect, but the library does include auto-throttling and other tricks to make sure the frame rate stays as high as possible and no effort is wasted updating effects that are far away compared to those closeby. "

This module is strictly client-sided, as it is built to try and reduce strain on the game. I don’t see why this would matter. The player’s may see different arcs, but that shouldn’t really be a problem. Each client will be in charge of loading the arcs, and the developer said that the clients will try to increase performance as much as possible, something that can’t be done on the server for individual players.

I’m looking for a fix to my own scripting, I don’t want other people’s work, nor do I want to use an open source script

I don’t see why you refuse to use a working script vs yours which you just said does not work. Buildthomas’ module was made to be as non performance heavy as possible. I don’t think you have an use case where his module would not work. If there’s something free, open source, and good, why not use it? :slight_smile:

1 Like

Because I’d rather improve than subject myself to using another’s work

Alright well you will have to do a lot more scripting in that function. It’s a pretty complicated thing to do, and I’m not advanced enough for that. Hope you get it working though! :grinning:

I fail to see how this is a bad thing. Open source modules like this are meant to be used because they perform a task that’s not easy to do.

You could’ve said this from the outset, instead of entertaining the idea of using the module.

If you’re really deadset on learning how to do this yourself, you can look at how the module is created to figure out how to go about your own method. I see you recently commented on an old thread that asks how a similar system is done. The solution offered is quite a good one, just create points between a start and end position and offset them slightly, and then connect them.

2 Likes

Found the solution while trial testing. Thanks.