Advertisement
9Simplicity9

Untitled

Jul 22nd, 2018
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local player = game:GetService("Players").LocalPlayer -- :GetService() is optional, if Players is renamed, this will still get Players, unlike game.Players
  2. local mouse = player:GetMouse() --GetMouse is deprecated but works and is more simpler than UserInputService in my opinion
  3. local position = CFrame.Angles(math.random(1,360), math.random(1,360), math.random(1,360))
  4.  
  5. function wave()
  6.     coroutine.resume(coroutine.create(function()
  7.         local pos = mouse.Hit -- CFrame, the target for part to move towards
  8.         local part = Instance.new("Part")
  9.         part.CFrame = player.Character.Torso.CFrame
  10.         part.Anchored = true -- Object is stationary, can only be moved when Position or CFrame is modified
  11.         part.CanCollide = false -- Objects can go through the part
  12.         part.Transparency = 0
  13.         part.Size = Vector3.new(1, 1, 1)
  14.         part.Parent = workspace
  15.         for i = 1, 20 do
  16.             wait()
  17.             part.Touched:Connect(function(hit)
  18.                     for i,v in pairs(hit.Parent:GetChildren()) do
  19.                         if v:IsA("Humanoid") == true then
  20.                             hit.Parent:FindFirstChild("Humanoid"):TakeDamage(math.huge)
  21.                     end
  22.                 end
  23.             end)
  24.             part.CFrame = part.CFrame:lerp(pos, i/20)
  25.             part.CFrame2 = part.CFrame + position
  26.             part.Transparency = part.Transparency + .05
  27.             part.Size = part.Size + Vector3.new(2, 2, 2)
  28.         end
  29.         if part.Transparency >= 1 then
  30.             part:Destroy()
  31.         end
  32.     end))
  33. end
  34.  
  35.  
  36. mouse.Button1Down:Connect(function() -- Whenever mouse is clicked
  37.     coroutine.resume(coroutine.create(function()
  38.         while wait() do
  39.             wave()
  40.         end
  41.     end))
  42.     -- Write the code now to move the part towards the position 'pos'
  43. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement