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

Lightning Spell Glitch ?

Asked by 8 years ago

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:


math.randomseed(tick()) function lightning(startPos,endPos,details) local mag = (startPos-endPos).magnitude local step = details.Step local waitTime = details.WaitTime local lightningModel = Instance.new("Model" , workspace) lightningModel.Name = "Lightning" local lastStart = startPos local debugMode = details.DebugMode local lightningEnd = endPos for i = 1,mag,mag/step do print(i) if waitTime > 0 then wait(waitTime) end local newEnd = endPos*Vector3.new(math.random(-2*mag/5,2*mag/5),math.random(-2*mag/5,2*mag/5),0) if i+(mag/step) == mag then print("LAST ONE") newEnd = endPos end local ray = Ray.new(lastStart,(newEnd-lastStart).unit*(mag/step)) local hit,rayEnd = workspace:FindPartOnRay(ray,(lightningModel)) local currentMag = (lastStart-rayEnd).magnitude local part = Instance.new("Part") part.Anchored = true part.CanCollide = false part.TopSurface = "Smooth" part.BottomSurface = "Smooth" part.FormFactor = "Custom" part.BrickColor = BrickColor.new(details.Color) part.Material = details.Material part.Transparency = details.Transparency part.Size = Vector3.new(.2,.2,currentMag) part.CFrame = CFrame.new(lastStart , rayEnd)*CFrame.new(0,0,-currentMag/2) part.Parent = lightningModel lastStart = rayEnd if debugMode then local p = Instance.new("Part") p.FormFactor = "Custom" p.Size = Vector3.new(.2,.2,.2) p.Anchored = true p.Material = "Neon" p.Position = rayEnd end lightningEnd = rayEnd end return lightningModel,lightningEnd end return lightning

Full module >.>

0
You need to include way more of your code and actually explain what's going on BlueTaslem 18071 — 8y
0
ok Rodrigo2003 76 — 8y
0
:P try to understand now Rodrigo2003 76 — 8y
0
You need to include ALL code necessary for us to answer this. I see there's a function lightning(), however I see no define function. Shawnyg 4330 — 8y
View all comments (3 more)
0
Need more code post all of your code so we can actually understand what is going on and the error from output Prioxis 673 — 8y
0
well if it is to fix Rodrigo2003 76 — 8y
0
You need Local script too? Rodrigo2003 76 — 8y

Answer this question