Advertisement
Guest User

uh ye

a guest
Apr 21st, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.43 KB | None | 0 0
  1. function TraceLine(Start, End, Offset_Min, Offset_Max, NUM_PARTS, SIZE_VARIES)
  2.     local Points = {Start}
  3.     local Magnitude = (End-Start).magnitude
  4.     local Space = 0
  5.     local Z_Range = (type(NUM_PARTS) == "number" and NUM_PARTS > 0) and math.modf(NUM_PARTS) or math.random(4,8)
  6.     local Point,X,Y,Z;
  7.    
  8.     local Offset_Min = Vector2.new(math.modf(Offset_Min.X),math.modf(Offset_Min.Y))
  9.     local Offset_Max = Vector2.new(math.modf(Offset_Max.X),math.modf(Offset_Max.Y))
  10.    
  11.    
  12.    
  13.     --pretty readable so u should know wut this does i guess
  14.    
  15.     if type(NUM_PARTS) == "number" and NUM_PARTS > 0 then
  16.         local n = 0;
  17.         local delMag = Magnitude;
  18.        
  19.         while n < NUM_PARTS - 1 do
  20.             X = math.random(Offset_Min.X,Offset_Max.X)
  21.             Y = math.random(Offset_Min.Y,Offset_Max.Y)
  22.            
  23.             if SIZE_VARIES then
  24.                 Z = delMag/(NUM_PARTS-n)*100
  25.                 Z = math.random(Z/1.5, Z)/10
  26.             else
  27.                 Z = Magnitude/NUM_PARTS
  28.             end
  29.            
  30.             Point = CFrame.new(Start,End) * CFrame.new(X, Y, -(Space + Z))
  31.             table.insert(Points,Point.p)
  32.            
  33.             Space = Space + Z
  34.             delMag = delMag - Z
  35.             n = n+1;
  36.         end
  37.     else
  38.         while Space < Magnitude - Z_Range do
  39.             X = math.random(Offset_Min.X,Offset_Max.X)
  40.             Y = math.random(Offset_Min.Y,Offset_Max.Y)
  41.            
  42.             Z = math.random(Z_Range/2, Z_Range)
  43.            
  44.             Point = CFrame.new(Start,End) * CFrame.new(X, Y, -(Space + Z))
  45.             table.insert(Points,Point.p)
  46.            
  47.             Space = Space + Z
  48.         end
  49.     end
  50.    
  51.     table.insert(Points,End)
  52.     return Points
  53. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement