i've worked out how to move a part (boat) to mouse.hit position...but would also like it to rotate face slowly toward hit point. plus if the mouse is hit a second time, how would i stop the function mid flow and restart the function, at its new position?
boat = game.Workspace.Part
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local time = 5
local increment = 0.1
local debounce = false
mouse.Button1Down:connect (function()
local mousecframe = mouse.Hit
local mouseposition = mousecframe.p
print ("mouse position on hit = ",mouseposition)
local newpos = Vector3.new(mouseposition.X,mouseposition.Y,mouseposition.Z)
print("newpos = ",newpos)
local diff = newpos - boat.Position
print("diff = ",diff)
local mag = diff.magnitude
print("mag = ",mag)
local Direction = CFrame.new(boat.Position, newpos).lookVector
print("direction is = ", Direction)
for n = 0, mag, increment do
print (n )
boat.CFrame = boat.CFrame + (Direction * increment) -- * CFrame.Angles(newpos)
wait( (time/mag) * increment )
end
end)
