Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make lightning?

Asked by 9 years ago

Yes. Lightning, not lighting, the thundery loud lightning. Yet again, I can't provide much code for this one, I guess the only code I can provide is..

1function CreateLightning()
2 
3end
4 
5MouseButton1Click:connect(CreateLightning)

or

1MouseButton1Click:connect(function()
2 
3end)

So what I'm trying to accomplish is an effect similar to that of Stravant's Lighting. I'm making an RPG and this will become really helpful! Thanks in advance, jakei181

1 answer

Log in to vote
0
Answered by
ImfaoXD 158
9 years ago

Get a brick and put this into a normal script not a local script. Also, insert a "ClickDetector" into the brick and you're good to go. I hope this helps. :)

01repeat wait() until game.Players.LocalPlayer and game.Players.LocalPlayer.Character and game.Players.LocalPlayer.Character:findFirstChild('Head') and game.Players.LocalPlayer:GetMouse()
02local plr = game.Players.LocalPlayer
03local char = plr.Character
04local head = char.Head
05local mouse = plr:GetMouse()
06 
07mouse.Button1Down:connect(function()
08local s,f = head.Position,mouse.Hit.p
09local hit,pos = workspace:FindPartOnRayWithIgnoreList(Ray.new(s,(f-s).unit*999),char:children())
10local dist = (s-pos).magnitude
11local lastp = s
12for i = 1,10 do
13local newp = (CFrame.new(s,pos)*CFrame.new(0,0,-i*(dist/10))).p+Vector3.new(math.random(-50,50)/20,math.random(-50,50)/20,math.random(-50,50)/20)
14local newdist = (lastp-newp).magnitude
15local p = Instance.new('Part',char) game:service('Debris'):AddItem(p,.5)
View all 28 lines...
0
Thanks a lot! Can you help me put this in a tool? jakei181 60 — 9y
0
let me give it a try. xD ImfaoXD 158 — 9y
0
Here you go bro! I find this in a free model and I fix it up a little. I hope this helps. :) ImfaoXD 158 — 9y
0
holy heck upvote this stuff its good, thank you bro greatneil80 2647 — 5y
Ad

Answer this question