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
- mouse.Button1Down:Connect(function() -- Whenever mouse is clicked
- local pos = mouse.Hit -- CFrame, the target for part to move towards
- local part = Instance.new("Part",workspace)
- 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
- while true do wait()
- part.CFrame = part.CFrame:lerp(pos, 0.1)
- part.Transparency = part.Transparency + .05
- end
- if part.Transparency = 1 then
- part:Destroy()
- end
- -- Write the code now to move the part towards the position 'pos'
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement