Help with a bug i can't fix and understand

The video is self explenatory, the card remains big, i don’t know why, i’ve been trying to fix it for 1 hour, but i can’t.

local function onMouseEnter(card : ImageLabel)
	
	if isDragging then currentlyEnlargedCard = nil return end

	if currentlyEnlargedCard and currentlyEnlargedCard ~= card then
		pendingEnlargedCard = card
		return
	end

	if not card:GetAttribute("IsBigger") then
		currentlyEnlargedCard = card
		card:SetAttribute("IsBigger",true)
		card.Parent.ZIndex = 100 --La carta va in primo piano
		tween = TweenService:Create(card,sizeTweenInfo,{Size = card:GetAttribute("OriginalSize") + PLUS_SIZE})
		tween:Play()
	end
end

local function onMouseLeave(card : ImageLabel)

	if currentlyEnlargedCard ~= card then pendingEnlargedCard = nil return end  --Quando esci da PendingEnlargedCard, ma non da CurrentlyEnlargedCard
	if isDragging then return end

	if card:GetAttribute("IsBigger") then
		currentlyEnlargedCard = nil
		card:SetAttribute("IsBigger",false)
		card.Parent.ZIndex = card:GetAttribute("DefaultZIndex")
		tween = TweenService:Create(card,sizeTweenInfo,{Size = card:GetAttribute("OriginalSize")})
		tween:Play()
	end

	if pendingEnlargedCard and pendingEnlargedCard ~= card then
		onMouseEnter(pendingEnlargedCard)
		pendingEnlargedCard = nil
	end
end

--Quando dragghi la carta, la puoi posizionare
local function onDragStart(card : ImageLabel)
	isDragging = true
	card.Parent.ZIndex = 100
	if not card:GetAttribute("IsBigger") then
		card:SetAttribute("IsBigger",true)
		currentlyEnlargedCard = card
		tween = TweenService:Create(card,sizeTweenInfo,{Size = card:GetAttribute("OriginalSize") + PLUS_SIZE})
		tween:Play()
	end
end
local function onDragEnd(card : ImageLabel)
	isDragging = false
	if tween and tween.PlaybackState == Enum.PlaybackState.Playing then
		tween:Cancel()
	end
	
	tween = TweenService:Create(card,sizeTweenInfo,{Size = card:GetAttribute("OriginalSize")})
	tween:Play()
	
	currentlyEnlargedCard = nil
	card.Parent.ZIndex = card:GetAttribute("DefaultZIndex")
	card.Position = handFrame[card.Parent.Name].Position + UDim2.new(0.5,0,0.5,0)
	card:SetAttribute("IsBigger",false)

	if pendingEnlargedCard and pendingEnlargedCard ~= card then
		onMouseEnter(pendingEnlargedCard)
		pendingEnlargedCard = nil
	end
end
External Media
2 Likes

bro say in words whats problem?

1 Like

The card should get bigger when im hovering on them, and smaller when i stop. I added a drag detector to drag the cards, when i drag, they get bigger, when i stop, they get smaller. The problem is that when i spam around drags while moving the mouse between the cards, the card stay big and it shouldn’t.

1 Like