I’m trying to make a part that can move up and down infinitely using tween service however there’s lots of lag and when I try to call two tween animations the part get stucked to the same position for ever
Here’s the outcome
local function translateDownFunc()
local translationSpeed = 3
local tweenInfoTranslate = TweenInfo.new(translationSpeed, Enum.EasingStyle.Linear, Enum.EasingDirection.In)
local goalTranslation = {Position = defaultPartPosition + Vector3.new(0, 3, 0)}
local goalTranslation2 = {Position = defaultPartPosition + Vector3.new(0, -3, 0)}
local translatePart = TweenService:Create(part, tweenInfoTranslate, goalTranslation)
local translatePart2 = TweenService:Create(part, tweenInfoTranslate, goalTranslation2)
translatePart:Play()
translatePart2:Play()
translateDownFunc()
end
translateDownFunc()
It work at the start but doesn’t repeat itself infinitely and sometimes the part instantly move to the y position and the animation isn’t smooth at all
What I’m trying to achieve basically is the part slowly moves at the start then it increases exponentially until the end goal but to achieve this with :Lerp() function which stands for Linear Interpolation I would basically have to change the interpolation value so like basically if I want to change the speed says at the start I want 0.2 and at the end 0.8 how do I achieve this ?
Alright :Lerp seems to be working fine but parts are teleporting and I have no idea why it does this annoying issue
local part = script.Parent
local lowerBound = part.Position - Vector3.new(0, 0.29, 0)
local upperBound = part.Position + Vector3.new(0, 0.25, 0)
local radiansPerSecond = math.rad(90) -- a quarter turn every second (we need to do this to maintain a consistent velocity), needs to be wrapped in math.rad as CFrame.Angles takes an arg in radians not degrees
local identityRotation = CFrame.identity.Rotation -- equivalent of CFrame.Angles(0, 0, 0)
local currentRotation = identityRotation -- our starting rotation
local isUp = true
--------------------------------------------
-- --
-- UP/DOWN --
-- --
--------------------------------------------
while true do
local now = tick()
wait()
if isUp == true then
for i = 1, 25, 0.1 do
-- math.sin returns a value between -1 and 1 so we first need to add 1 to get a number between 0 and 2, then divide by 2 (multiply by 0.5) to get a number between 0 and 1 so it does not exceed the boundaries we set above
local position = upperBound:Lerp(lowerBound, (math.sin(i)) * 1)
-- finally apply our current CFrame to the part's CFrame
part.CFrame = CFrame.new(position)
wait()
end
isUp = false
elseif isUp == false then
print("LAG IS HAPPENING")
for i = 1, 25, 0.1 do
-- math.sin returns a value between -1 and 1 so we first need to add 1 to get a number between 0 and 2, then divide by 2 (multiply by 0.5) to get a number between 0 and 1 so it does not exceed the boundaries we set above
local position = lowerBound:Lerp(upperBound, (math.sin(i)) * 1)
-- finally apply our current CFrame to the part's CFrame
part.CFrame = CFrame.new(position)
wait()
end
isUp = true
end
print("ANIMATION FINISHED")
end
Trying to make parts go at differents heights and speed and not start and end at the same time