Trying to make a part accelerate and deaccelerate

My script moves a part up and down. I want it to make a part accelerate when starting to move and deaccelerate when getting close to the end.
I’m not sure which EasingStyle to use. I have tried a few but they didn’t give me the result I wanted. Based off of what I saw the script should give me the results I want but it’s not. The part accelerates but doesn’t deaccelerate.
I used this script:

local tweenService = game:GetService("TweenService")

local part = script.Parent

local info = TweenInfo.new(3, Enum.EasingStyle.Exponential, Enum.EasingDirection.Out, 0 --[[the amount of times the tween repeats. Zero if you do not add it]], false --[[Tells the tween to reverse or not. False if you do not add it]])
local endPos = part.Position + Vector3.new(0, 0.25, 0)

local info2 = TweenInfo.new(3, Enum.EasingStyle.Exponential, Enum.EasingDirection.In, 0 --[[the amount of times the tween repeats. Zero if you do not add it]], false --[[Tells the tween to reverse or not. False if you do not add it]])
local endPos2 = part.Position + Vector3.new(0, -0.25, 0)

local info3 = TweenInfo.new(3, Enum.EasingStyle.Exponential, Enum.EasingDirection.Out, 0 --[[the amount of times the tween repeats. Zero if you do not add it]], false --[[Tells the tween to reverse or not. False if you do not add it]])
local endPos3 = part.Position + Vector3.new(0, -0.25, 0)

local info4 = TweenInfo.new(3, Enum.EasingStyle.Exponential, Enum.EasingDirection.In, 0 --[[the amount of times the tween repeats. Zero if you do not add it]], false --[[Tells the tween to reverse or not. False if you do not add it]])
local endPos4 = part.Position + Vector3.new(0, 0.25, 0)

while true do
	tweenService:Create(part, info, {Position = endPos}):Play()
	task.wait(3)
	tweenService:Create(part, info2, {Position = endPos2}):Play()
	task.wait(3)
	tweenService:Create(part, info3, {Position = endPos3}):Play()
	task.wait(3)
	tweenService:Create(part, info4, {Position = endPos4}):Play()
	task.wait(3)
end

I don’t really understand what you mean. But if you wanna accelerate something you can use their velocity property. Y = UP
-Y = down

I made a slight edit to the topic. The part accelerates but it doesn’t deaccelerate/slow down. It just stops when it reaches the destination.

I ended up changing the script a bit. I noticed that it didn’t go down. I managed to find a solution to this.

local tweenService = game:GetService("TweenService")

local part = script.Parent

local info = TweenInfo.new(2, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0 --[[the amount of times the tween repeats. Zero if you do not add it]], true --[[Tells the tween to reverse or not. False if you do not add it]])
local endPos = part.Position + Vector3.new(0, 0.5, 0)

local info2 = TweenInfo.new(2, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0 --[[the amount of times the tween repeats. Zero if you do not add it]], true --[[Tells the tween to reverse or not. False if you do not add it]])
local endPos2 = part.Position + Vector3.new(0, -0.5, 0)


while true do
	tweenService:Create(part, info, {Position = endPos}):Play()
	task.wait(4)
	tweenService:Create(part, info2, {Position = endPos2}):Play()
	task.wait(4)
end

Lock the velocity. Just make a bool variable that changes based on if its at the start or not. then if its at the start you can make a loop that keeps setting the same velocity endlessly so it never slows down. and then when the bool becomes false the loop ends because it reached the destination.

But you could just add a humanoid to the part and use :MoveTo()

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.