Advertisement
Descaii

FireBalls

Mar 4th, 2014
318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.00 KB | None | 0 0
  1. -- FireBalls --
  2. Player = game.Players.LocalPlayer
  3. Mouse = Player:GetMouse()
  4. function Path(Block,Speed,Color)
  5.     local Parts = {}
  6.     game:GetService("RunService").RenderStepped:connect(function()
  7.         if Block:IsDescendantOf(Workspace) then
  8.             local P = Parts[#Parts]
  9.             if P then
  10.                 local G = Instance.new("Part",Workspace)
  11.                 if Color then
  12.                     G.BrickColor = Color
  13.                 end
  14.                 G.Anchored = true
  15.                 G.FormFactor = "Custom";G.CanCollide = false
  16.                 G.TopSurface = "Smooth"
  17.                 G.BottomSurface = "Smooth"
  18.                 local Dis = ((P.CFrame*CFrame.new(0,0,-P.Size.Z/2)).p-Block.CFrame.p).magnitude
  19.                 G.Size = Vector3.new(0,0,Dis)
  20.                 G.CFrame = CFrame.new((P.CFrame*CFrame.new(0,0,-P.Size.Z/2)).p,Block.CFrame.p)*CFrame.new(0,0,-Dis/2)
  21.                 table.insert(Parts,G)
  22.             else
  23.                 local G = Instance.new("Part",Workspace)
  24.                 G.Anchored = true
  25.                 G.FormFactor = 'Custom'
  26.                 G.Size = Vector3.new(0,0,0)
  27.                 G.CFrame = Block.CFrame
  28.                 table.insert(Parts,G)
  29.             end
  30.         end
  31.         for i,v in pairs(Parts) do
  32.             if v.Transparency < 1 then
  33.                 v.Transparency = v.Transparency +Speed
  34.             else
  35.                 table.remove(Parts,i)
  36.                 v:Destroy()
  37.             end
  38.         end
  39.     end)
  40. end
  41. local Balls = {}
  42. local All = {}
  43. function MakeBall()
  44.     local P = Instance.new("Part",Player.Character)
  45.     P.Anchored = true
  46.     P.FormFactor = "Custom"
  47.     P:breakJoints()
  48.     P.Size = Vector3.new(1,1,1)
  49.     P.CanCollide = false
  50.     P.CFrame = CFrame.new(0,20,0)
  51.     local PM = Instance.new("SpecialMesh",P)
  52.     PM.MeshType = "Sphere"
  53.     Path(P,0.1)
  54.     local B = {}
  55.     B.Velocity = Vector3.new(0,0,0)
  56.     B.Target = Vector3.new(0,0,0)
  57.     B.Part = P
  58.     table.insert(Balls,B)
  59.     table.insert(All,B)
  60.     return B
  61. end
  62. for i = 1,3 do
  63.     print(MakeBall())
  64. end
  65. local N = 0
  66. game:GetService("RunService").RenderStepped:connect(function()
  67.     N = N +1
  68.     for i,v in pairs(Balls) do
  69.         if v.Part:IsDescendantOf(Workspace) then
  70.             if not v.Shooting then
  71.                 v.Target = (
  72.                     Player.Character.Torso.CFrame
  73.                     *CFrame.Angles(0,((math.rad(360)/#Balls)*i)+math.rad(N),0)
  74.                     *CFrame.new(0,math.sin(i+N/10),#Balls*2)
  75.                     *CFrame.Angles(0,math.rad(N*3),0)
  76.                     *CFrame.new(0,0,2)
  77.                 ).p
  78.                 v.Velocity = -(v.Part.Position-v.Target)*0.1
  79.             end
  80.         else
  81.             table.remove(Balls,i)
  82.         end
  83.     end
  84.     for i,v in pairs(All) do
  85.         if v.Part:IsDescendantOf(Workspace) then
  86.             if v.Shooting then
  87.                 local hit,pos = Workspace:FindPartOnRay(Ray.new(v.Part.CFrame.p,(v.Part.CFrame*CFrame.new(0,0,2)).p),game.Players.LocalPlayer.Character)
  88.                 if not hit then
  89.                     v.Part.CFrame = v.Part.CFrame +v.Velocity
  90.                 elseif v.Shooting then
  91.                     v.Part.CFrame = CFrame.new(pos)
  92.                     wait(0.5)
  93.                     Instance.new("Explosion",Workspace).Position = v.Part.Position
  94.                     v.Part:Destroy()
  95.                 end
  96.             end
  97.         else
  98.             table.remove(All,i)
  99.         end
  100.     end
  101. end)
  102. Mouse.Button1Down:connect(function()
  103.     local B = Balls[1]
  104.     if B then
  105.         table.remove(Balls,1)
  106.         B.Shooting = true
  107.         B.Velocity = -(B.Part.Position-Mouse.Hit.p)*0.1
  108.     end
  109. end)
  110. Mouse.KeyDown:connect(function(k)
  111.     if k == "n" then
  112.         if #Balls < 6 then
  113.             MakeBall()
  114.         end
  115.     end
  116. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement