Button favorite system tween help

Hi, I’m having a problem with my favoriting system. When a player hovers over an item, a tween slightly enlarges it. But if they favorite the item, the tween resets because the entire inventory rebuilds on any state change, this effect looks very jarring. How can I prevent this from affecting the tween?

By doing this i’ve probably made it in a very odd and unusual way but I’d rather not recode the entire thing, The server is also what activates updating the inventory (So I can data store everything)

2 Likes

It would be hard to give you advice since there isn’t no code provided, although I can suggest this, since you mentioned States, you already know if the player is hovering over (State.Hovering?) it if they are able to favorite it, when they click it, just set the Frame Size of the Favoriting item to the slightly enlarged size?

I hope this makes sense I tried to word it the best way I could

I’m simply using mouse enter and mouse leave then tweening,
And when favorite is activatedor a weapon is equipped everything gets deleted and recreated

function InventoryClient.UpdateInventoryDisplay()
	--If we are currently in the process of updating, add debounce, then when no debounce, update if in while wait queue
	while InventoryClient.UpdateDisplayDebounce do task.wait() end
	InventoryClient.UpdateDisplayDebounce = true
	
	-- Clearing old item frames
	for _,item:Frame in invMain:GetDescendants() do
		if item.ClassName == "Frame" then
			item:Destroy()
		end
	end

-- Code
			button.MouseButton1Down:Connect(function()
				InventoryClient.EquipState(itemInfo, button)
			end)
			
			-- Favoriting items
			favorite.MouseButton1Down:Connect(function()
				InventoryClient.FavoriteState(itemInfo.Name)
			end)
			
			-- Hover
			button.MouseEnter:Connect(function()
				local tween = TweenService:Create(button, tweenHover, {Size = UDim2.new(1.03,0,1.03,0)})
				tween:Play()
			end)
			
			button.MouseLeave:Connect(function()
				local tween = TweenService:Create(button, tweenHover, {Size = UDim2.new(1,0,1,0)})
				tween:Play()
			end)
			```

So your Item Slot enlarges/shrinks everytime the star is clicked not hovered on which is good because it should be a simple rework.

Why are you resetting the page state with a favorite? You could have a separate function to control the favorite button to change to Favorited/Unfavorited with your noise .

It seems like bad practice to delete the whole Inventory and recreate it, especially on lower end devices. Could you do a small rework and just update the frame directly? Make a separate function and call it like InventoryClient.UpdateFrame(Frame: Frame) then just update it how you want it. The issue is because you’re rebuilding the frame which unhovers it and gets all wonky. At least my assumption

Yes you’re right thats definitely the case, if thats my only option Ill go ahead and rework it

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