Need help with tween logic

Below I have attached a video for more clarity on my issue:

Mainly what’s happening, I have a open and close tween animation. It does what its suppose to do when I click a button, it tweens the open animation and close animation, but lets say button A clicked and its in its open state and I click on button B, it closes it instead of making a new open tween.

Video:

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

function TweenLoader:AnimateElement(element: GuiObject, attribute: string)
	if not element then return end -- nil
	if not attribute or attribute == "" then return end
		
	local existingAnim = activeElementTweens[element]
	if existingAnim then
		existingAnim:Stop()
		activeElementTweens[element] = nil
		return
	end
		
	local success, result = pcall(require, TweenFolder:FindFirstChild(attribute))

	if not success then
		warn{`Error Occured || {attribute} module failed to run. {result}`}
		return
	end
	
	-- Creates new tween object if it does not exist
	local tween = result.new(element)
	activeElementTweens[element] = tween
	tween:Play()
end

It seems the issue lies within the result class. Please share its source code

They all have their own class, but this is the one im working with at the very moment. For TweenService I’m using the TweenPlus module ([V2] Tween+ | Advanced & performant tweening)

local SlideIn = {}
SlideIn.__index = SlideIn

local positionCache = {}

function SlideIn.new(ui: GuiButton)
	local self = setmetatable({}, SlideIn)
	self.uiInstance = ui
	
	if not positionCache[ui] then
		positionCache[ui] = ui.Position
	end
	self.originalPosition = positionCache[ui]
	self.hiddenPosition = self.originalPosition + UDim2.fromScale(1, 0)

	ui.Position = self.hiddenPosition

	return self
end


function SlideIn:Play(duration)
	duration = duration or 0.5
	
	if self.ActiveTween then
		self.ActiveTween:Reset()
	end
	
	self.ActiveTween = TweenService(
		self.uiInstance,
		{
			Position = self.originalPosition
		},
		{
			Time = duration,
			EasingStyle = "Quad",
			EasingDirection = "Out"
		}
	)
	
	self.ActiveTween:Start()
end

function SlideIn:Stop(duration)
	if self.ActiveTween then
		self.ActiveTween:Stop()
	end
	
	duration = duration or 0.5
	
	self.ActiveTween = TweenService(
		self.uiInstance,
		{
			Position = self.hiddenPosition
		},
		{
			Time = duration,
			EasingStyle = "Quad",
			EasingDirection = "In"
		}
	)

	self.ActiveTween:Start()
	return self.ActiveTween
end

return SlideIn

Hey man, I was able to figure out the problem so its all good now.