Advertisement
9Simplicity9

Untitled

Jul 21st, 2018
207
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.  
  4.  
  5. mouse.Button1Down:Connect(function() -- Whenever mouse is clicked
  6. local pos = mouse.Hit -- CFrame, the target for part to move towards
  7. local part = Instance.new("Part",workspace)
  8. part.CFrame = player.Character.Torso.CFrame
  9. part.Anchored = true -- Object is stationary, can only be moved when Position or CFrame is modified
  10. part.CanCollide = false -- Objects can go through the part
  11. part.Transparency = 0
  12. while true do wait()
  13. part.CFrame = part.CFrame:lerp(pos, 0.1)
  14. part.Transparency = part.Transparency + .05
  15. end
  16. if part.Transparency = 1 then
  17. part:Destroy()
  18. end
  19. -- Write the code now to move the part towards the position 'pos'
  20.  
  21. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement