How to make a script create lightning bolt

How to make a script that creates a lightning bolt

Can we get more info? Like what would the lightning bolt do, when should it spawn, where should it spawn from, what do you want it to look like.

When you execute the command using kohls admin :smite plrname

you can see how it looks and it would spawn where its told to

Do you have an admin system set up, or do you just want one command?

i dont have a admin system but i just want a script that creates the actual lightning bolt

Im not gonna spoonfeed you code, but if you know how to create part instances then do that and have them spawn where you want them. If you don’t know how to do that then study up on the following:

- Instances
- Parts
- CFrame
- Chat Events
- Remote Events / Remote Functions
- Lighting and Effects

wdym by lightning and effects also i know using instance makes a part but i just want to know how to make random curves on the lightning bolt

If you are looking for randomizing the angles of stuff, that’s gonna be a bit odd.

I’m no expert on this, so this ‘code’ probably won’t work the best

-- so this is just for your 'random curves' thing

local randomnumber = math.random(1,100)

--change the rotation of the piece by the random number

part.Orientation = part.Orientation + Vector3.new(part.Oreintation.X, Part.Orientation,Y, part.Orientation.Z + randomnumber)

--again don't quote me on this

Does this help in any way?

1 Like

It most likely won’t as Orientation is local, CFrame will work better. Also you’ll have to make the ends actually meet to make it look more like a lightning bolt

1 Like

Again, i did say I wasn’t an expert. Just showing the general idea.

1 Like

Yes, but I commented that to help you and OP understand why CFrame is better, no way was I trying to be condescending. I apologize if I came off that way. Just trying to push everyone in the right direction.

1 Like

Yeah I saw another post of someone asking about this but the code is complicated so I could just copy it but I want to at least understand it

ask the OP of the code, or DM them and ask, I’m sure they’ll explain it more, if you post it here I might be able to explain it as well.

wdym op of code? the person who posted it

There are some beam lighting effects of that is what you want. If not then I could give you some logic on how you would go about creating something like this.

  1. Define a start and end position and also how many segments the bolt will have.
  2. Divide the difference between the two points by the number of segments. Alternatively you can lerp which is easier. (If you want 3 segments then lerp 1/3,2/3) Note: there is 1 less point than your segment so you need to be aware of the edge cases.
  3. Use the Random object to offset the points. If your lightning will only be going up and down then you only need to apply it to the X and Z axis. If you want it to be going from anywhere to anywhere then you will need to get a perpendicular Vector you can get one using the Cross product.
  4. Create parts resize them to match the distance between each point and CFrame them. (Gou can use Beams and attachments if you don’t like parts)

Then you should have your very own lightning bolt.

There are some tutorials on yt but I don’t recommend them.

1 Like

image

1 Like

wood sticks falling from sky >:D

1 Like

Lightning bamboo appears to be from this thread:

How to properly generate lightning - Help and Feedback / Scripting Support - DevForum | Roblox

This thread didn’t help?