Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local player = game:GetService("Players").LocalPlayer -- :GetService() is optional, if Players is renamed, this will still get Players, unlike game.Players
- local mouse = player:GetMouse() --GetMouse is deprecated but works and is more simpler than UserInputService in my opinion
- function wave()
- coroutine.resume(coroutine.create(function()
- local pos = mouse.Hit -- CFrame, the target for part to move towards
- local part = Instance.new("Part")
- part.CFrame = player.Character.Torso.CFrame
- part.Anchored = true -- Object is stationary, can only be moved when Position or CFrame is modified
- part.CanCollide = false -- Objects can go through the part
- part.Transparency = 0
- part.Size = Vector3.new(1, 1, 1)
- part.Parent = workspace
- for i = 1, 20 do
- wait()
- print(i)
- part.Touched:Connect(function(hit)
- for i,v in pairs(hit.Parent:GetChildren()) do
- if v:IsA("Humanoid") == true then
- hit.Parent:FindFirstChild("Humanoid"):Destroy()
- end
- end
- end)
- part.CFrame = part.CFrame:lerp(pos, i/20)
- part.Transparency = part.Transparency + .05
- part.Size = part.Size + Vector3.new(2, 2, 2)
- end
- if part.Transparency >= 1 then
- part:Destroy()
- end
- end))
- end
- mouse.Button1Down:Connect(function() -- Whenever mouse is clicked
- coroutine.resume(coroutine.create(function()
- while wait() do
- wave()
- end
- end))
- -- Write the code now to move the part towards the position 'pos'
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement