local Time = 10
local TweenInfo = TweenInfo.new(
Time,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
0,
false,
0
)
TweenService:Create(Part, TweenInfo, {CFrame = CFrame.new(0, 10, 0)}):Play()
But to tween something, you have to tell the TweenInfo how long it will take for the part to get to that location. How can I tween a part based on how fast I want it to go rather than how long it should take?
How fast you want it, it’s the speed you give to it, so, if you change the ‘Time’ to 0.1, it will go really fast, else, if you change time to, 100, it will go really slow. I think that’s what you mean, else if you’re doing something like bullets, you can just do a loop to move it absolubtly fast, and make it goes down like in real life right, is that what you mean?
Oh like getting velocity of the part right, I do not know if tweenservice change velocity which I don’t think so, because it’s changing CFrame, probably somethin like diving the time and for the new cframe, I really do not know, not really experienced with this stuff as dividing, kind of new or / * ^ % and more, lol
It’s something you’ll have to solve for manually based on what you’re tweening.
Basically, Speed = Distance / Time. If you want to solve for time, you’ll be calculating Distance/Speed.
In the case of tweening a part’s position, if you have a starting point and a destination point both represented by Vector3s, you can subtract the destination point by the starting point, then take the magnitude of the resulting vector to get the distance. If you divide the magnitude of the resulting vector by the speed, you’ll get the time it should take to cover that distance for that speed.
Yeah, speed would be defined by you in a local variable. All that matters is that speed must be positive. Naturally, higher speed means a faster tween. If speed wasn’t given, you wouldn’t be able to solve for time.
I’ve had to work on this for my own game. Here’s basically the formula being put into action.
local Speed = 16
function GetTime(Distance, Speed)
-- Time = Distance / Speed
local Time = Distance / Speed
return Time
end
local NewPoint = Points:WaitForChild(""..i) -- New selected point/node
local Distance = (Model.PrimaryPart.Position - NewPoint.Position).magnitude -- Get the distance between the current position and the next node
local Time = GetTime(Distance, Speed) -- Calculate the time
print(Time)
local NewTweenInfoTable = TweenInfo.new(
Time, -- Time
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
0, -- RepeatCount (-1 = Infinite)
false, -- Reverse tween after finishing
0 -- DelayTime
)
-- Then you would make the Tween with the TweenInfo