This is my take on generating lightning effects. This was adapted and heavily modified from a YouTube tutorial.
This module has several features:
- Simple to use. Just specify the starting and ending points as Vector3 and a profile. If the profile is not defined, then it defaults to profile 1.
- Each profile can specify one or more lightning bolts. However, I wouldn’t go beyond 6 or 7 bolts for performance reasons.
- Profile data for each lightning bolt specifies the zig-zag offset, size, segment length, segment length jitter, and color.
- Designed to work on both the client and the server.
By using profiles, a predefined style of bolt can be called up on demand without the need of specifying complex parameters each time a lightning bolt is needed. The included rbxl file contains everything that you need to get started. It uses a server script to trigger the effect on the client using a remote event, which is how it should be done.
SHOWCASE
https://vimeo.com/767369721
DEMO FILE
Lightning Demonstration.rbxl (46.4 KB)
7 Likes
Oh hey this seems reliable!
I’ve been trying to figure out how to use other lightning modules for a while now, but my brain cells can NOT help. But this seems easy to use! I’ll try this right now!
Thank you so much.
Ok so funny question: i quite literally DO NOT know how to use it.
What do I place in the brackets? (I know It should be Vector3s but still, didn’t work.)
Here’s what I tried to do:
This is also inside a LocalScript by the way.
local r = require(game:GetService("ReplicatedStorage").Lightning)
r.bolt(Vector3.new(0, 0, 0), Vector3.new(1, 10, 1), 1)
All the code you need is in the three scripts in the attached file. However, the code that you posed does work. The problem is that the lightning bolts only last 0.2 seconds. So you need to put your code in a loop so it does it continuously.
local r = require(game:GetService("ReplicatedStorage").Lightning)
while true do
task.wait(0.2)
r.bolt(Vector3.new(0, 0, 0), Vector3.new(1, 10, 1), 1)
end
With your code, by the time your character has loaded, the bolt has already been rendered and destroyed before you even see it on your screen.
Oh, it was that simple? so stupid of me…
Anyhow, Thanks!
I’m gonna use this in future projects.