After a little bit of intense brain explosions I at least got your code to move the part.
local Workspace = game:GetService("Workspace")
local part = Workspace.Part
local areaMin = Vector3.new(0, 0, 0)
local areaMax = Vector3.new(20, 20, 20)
local randomDirection = Vector3.new(
math.random(areaMin.X, areaMax.X),
math.random(areaMin.Y, areaMax.Y),
math.random(areaMin.Z, areaMax.Z)
)
local startPosition = part.Position
local endPosition = randomDirection
local duration = 5 -- seconds
local startTime = tick()
while tick() - startTime < duration do
local interpolationValue = (tick() - startTime) / duration
local currentPosition = part.CFrame.Position:Lerp(endPosition, interpolationValue)
part.CFrame = CFrame.new(currentPosition)
wait()
end
Try this and see what you think. I am a noob with lerp but at least I did something with it