Lightning Spell Glitch ?
Please include the code which you are trying to use, so the community will be better-equipped to help you with your problem.
I have a script that can launch a Lightning by hand to the desired place, but there is a problem in the vector that will position it in a certain position of the map.
how can I fix?
The script:
01 | math.randomseed(tick()) |
03 | function lightning(startPos,endPos,details) |
05 | local mag = (startPos-endPos).magnitude |
06 | local step = details.Step |
07 | local waitTime = details.WaitTime |
09 | local lightningModel = Instance.new( "Model" , workspace) |
10 | lightningModel.Name = "Lightning" |
12 | local lastStart = startPos |
13 | local debugMode = details.DebugMode |
14 | local lightningEnd = endPos |
16 | for i = 1 ,mag,mag/step do |
21 | local newEnd = endPos*Vector 3. new(math.random(- 2 *mag/ 5 , 2 *mag/ 5 ),math.random(- 2 *mag/ 5 , 2 *mag/ 5 ), 0 ) |
22 | if i+(mag/step) = = mag then |
26 | local ray = Ray.new(lastStart,(newEnd-lastStart).unit*(mag/step)) |
27 | local hit,rayEnd = workspace:FindPartOnRay(ray,(lightningModel)) |
29 | local currentMag = (lastStart-rayEnd).magnitude |
30 | local part = Instance.new( "Part" ) |
32 | part.CanCollide = false |
33 | part.TopSurface = "Smooth" |
34 | part.BottomSurface = "Smooth" |
35 | part.FormFactor = "Custom" |
37 | part.BrickColor = BrickColor.new(details.Color) |
38 | part.Material = details.Material |
39 | part.Transparency = details.Transparency |
41 | part.Size = Vector 3. new(. 2 ,. 2 ,currentMag) |
42 | part.CFrame = CFrame.new(lastStart , rayEnd)*CFrame.new( 0 , 0 ,-currentMag/ 2 ) |
43 | part.Parent = lightningModel |
49 | local p = Instance.new( "Part" ) |
50 | p.FormFactor = "Custom" |
51 | p.Size = Vector 3. new(. 2 ,. 2 ,. 2 ) |
60 | return lightningModel,lightningEnd |
Full module >.>