-- Tween variables

local tweenInfo = TweenInfo.new(
	TWEEN_TIME,  -- Time
	Enum.EasingStyle.Quad,  -- EasingStyle
	Enum.EasingDirection.InOut,  -- EasingDirection
	-1,  -- RepeatCount (when less than zero the tween will loop indefinitely)
	true  -- Reverses (tween will reverse once reaching its goal)
)
local function startTween()
	-- If the part is already tweening, prevent it from starting a new tween
	if inTween == true then
		return
	end
	-- Calculate new CFrame for part position
	local offsetCFrame = CFrame.new(0, TWEEN_MOVE_DISTANCE, 0)
	local newCFrame = partToTween.CFrame:ToWorldSpace(offsetCFrame)
	-- Create a tween and play it
	local tweenPart = TweenService:Create(partToTween, tweenInfo, {CFrame = newCFrame})
	tweenPart:Play()
	inTween = true
	-- On tween completion, make part ready for another tween
	tweenPart.Completed:Connect(function()
		inTween = false
	end)
end

startTween()  -- Start the animation
