Advertisement
DutchDeveloper

fireworksstufff

Jun 13th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.27 KB | None | 0 0
  1. -- Boring support functions
  2. local rad = math.pi / 180
  3. local deg = 180 / math.pi
  4.  
  5. function UDimToVec2(UDim)
  6.     return Vector2.new(UDim.X.Offset, UDim.Y.Offset)
  7. end
  8.  
  9. function Vec2ToUDim(Vec2)
  10.     return UDim2.new(0, Vec2.X, 0, Vec2.Y)
  11. end
  12.  
  13. function CreateAFrame()
  14.     local Frame = Instance.new("Frame")
  15.     Frame.Parent = ScreenGui
  16.     Frame.BorderSizePixel = 0
  17.     Frame.BackgroundColor3 = Color3.new(1, 1, 1)
  18.     Frame.BackgroundTransparency = .5
  19.    
  20.     return Frame
  21. end
  22.  
  23. local Trails = 10
  24. local c1Magnitude = 100
  25. local c2Magnitude = 200
  26.  
  27.  
  28. function ExplodeFirework(c0)
  29.     for i = 1, Trails do
  30.         local InitialRotation = (360 / Trails) * i
  31.         local c1 = c0 + (Vector2.new(math.cos(InitialRotation) * deg, math.sin(InitialRotation) * deg).unit * c1Magnitude)
  32.        
  33.         local Holder = CreateAFrame()
  34.         Holder.Rotation = InitialRotation
  35.         Holder.Position = Vec2ToUDim(c0)
  36.        
  37.         local Spark = CreateAFrame()
  38.         Spark.Parent = Holder
  39.         Spark.Name = "Spark"
  40.         Spark.Position = UDim2.new()
  41.         Spark.Size = UDim2.new(0, 3, 0, (c1 - c0).magnitude)
  42.         Spark.BackgroundColor3 = Color3.new(1, 0, 0)
  43.  
  44.         local Holder = CreateAFrame()
  45.         Holder.Position = Vec2ToUDim(c1)
  46.         Holder.Size = UDim2.new(0, 5, 0, 5)
  47.         Holder.Position = Vec2ToUDim(c1)
  48.         Holder.BackgroundColor3 = Color3.new(0, 1, 0)
  49.  
  50.     end
  51. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement