Im trying to move smoothly an object (in this case a chairlift) from every point with a costant speed, with using only a script.
The problem I had is that the TweenService uses time to reach the other point.
I’ve tried searching and I’ve finded a problem like this, but it worked only for one point, and it slows down at the next points and seems to not work.
If someone already know how to move at costant speed from point to point can put the solution, it will really help!
that’s because it uses time, but is true that it can also be used for this, but the problem is that the speed need to have the possibility to be changed, and I dont really know how to make all the chairlifts change speed while moving in TweenService, so I prefer using something like Lerp, that always update the position
and that is a solution I’ve tried, but I still need to make it work correctly, because I dont know how to update the position of the part at every point with calculating everytime the time it needs to take
repeat task.wait(0.01)
part.CFrame.Position += Vector3.new(0,0,0.1) — edit to the speed u want it to move and the direction
until part.CFrame.Position == (desired position)
It’s pretty simple let me show you :
You have to do some maths.
local TweenService = game:GetService("TweenService")
local Speed = 12
local Nodes = workspace.Nodes
local Part = script.Parent
for i=1, #Nodes:GetChildren() do
local Distance = (Nodes["Node" ..i].Position - Part.Position).Magnitude
local Time = Distance / Speed
local Info = TweenInfo.new(Time, Enum.EasingStyle.Linear)
local Tween = TweenService:Create(Part, Info, {CFrame = Nodes["Node" ..i].CFrame})
Tween:Play()
Tween.Completed:Wait()
end
It will calcul each time the distance from the target node and the part