generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Lightning.

Previous Thread :: Next Thread 
TheCoderOfLua is not online. TheCoderOfLua
Joined: 12 Apr 2016
Total Posts: 1599
14 Jun 2016 11:23 PM
local function newRay(point1,point2,ignore)
local ray = Ray.new(point1, (point1 - point2).unit * (point1-point2).magnitude)
local part, position = workspace:FindPartOnRay(ray, ignore, false, true)
local beam = Instance.new("Part", workspace)
beam.BrickColor = BrickColor.new("Bright red");
beam.FormFactor = "Custom";
beam.Material = "Neon";
beam.Transparency = 0.15;
beam.Anchored = true;
beam.Locked = false;
beam.CanCollide = false;
local distance = (point1 - position).magnitude
beam.Size = Vector3.new(1, 1, distance)
beam.CFrame = CFrame.new(point1, position) * CFrame.new(0, 0, distance / 2)
end

local function RandomLightning(point1, point2)
local splits = math.random(5,10)
local param1 = -3;
local param2 = 3;
local randomPoints = {};
for i = 1, splits, 1 do
local POINT = point1:Lerp(point2, i/splits);
local x = math.random(param1,param2)
local y = math.random(param1,param2)
local z = math.random(param1,param2)
POINT = POINT + Vector3.new(x,y,z)
table.insert(randomPoints, POINT);
end
for i = 0, splits-1, 1 do
local a = randomPoints[i];
if i == 0 then
a = point1;
end
newRay(a, randomPoints[i+1])
end
end
wait(3)
RandomLightning(game.Workspace.Part1.Position, game.Workspace.Part2.Position)












This is my script to make lightning. It finds two points, makes more points with a little distortion between them, then connects all the points.


But when it generates sometimes one or two of the beams dont get generated, and theres no errors.


Thanks guys. Nothing wrong with beam script, look into RandomLightning for bugs
Report Abuse
TheCoderOfLua is not online. TheCoderOfLua
Joined: 12 Apr 2016
Total Posts: 1599
14 Jun 2016 11:28 PM
ftf
Report Abuse
TheCoderOfLua is not online. TheCoderOfLua
Joined: 12 Apr 2016
Total Posts: 1599
14 Jun 2016 11:35 PM
fvxhg
Report Abuse
TheCoderOfLua is not online. TheCoderOfLua
Joined: 12 Apr 2016
Total Posts: 1599
14 Jun 2016 11:54 PM
Like the stravants lightning gear cmon guys
Report Abuse
Grevok is not online. Grevok
Joined: 07 Jul 2013
Total Posts: 1652
14 Jun 2016 11:57 PM
math.random
Report Abuse
TheCoderOfLua is not online. TheCoderOfLua
Joined: 12 Apr 2016
Total Posts: 1599
15 Jun 2016 03:14 PM
Cmon dont be stupid man
Report Abuse
TheCoderOfLua is not online. TheCoderOfLua
Joined: 12 Apr 2016
Total Posts: 1599
15 Jun 2016 04:09 PM
asdasdasd
Report Abuse
Despawned is not online. Despawned
Joined: 06 Apr 2013
Total Posts: 12569
15 Jun 2016 04:11 PM
print("Hello World!")

totally fixes it man
Report Abuse
TheCoderOfLua is not online. TheCoderOfLua
Joined: 12 Apr 2016
Total Posts: 1599
15 Jun 2016 04:16 PM
You guys are messing with me
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image