Hovering the cursor over a frame

  1. What do you want to achieve?
    I want that when I hover the cursor over the frame, the preview of the item and all its details should be activated

  2. What is the issue?
    Script does not throw errors, but does not execute

local inventoryUI = gui.MainInventory
local playerInventory = gui.MainInventory.Inventory.BackpackBG.Backpack.InventoryList

local isHovering = false

local function itemDetails()
	for i, itemButton in pairs(playerInventory) do
		if itemButton.ClassName == "ImageButton" and itemButton.Name ~= "ExampleItem" then
			
			itemButton.MouseEnter:Connect(function()
				isHovering = true
			end)
			
			itemButton.MouseLeave:Connect(function()
				isHovering = false
			end)

			RunService.RenderStepped:Connect(function()
				toolDetails.Position = UDim2.fromOffset(playerMouse.X, playerMouse.Y)
				toolDetails.Visible = isHovering
			end)
			
			inventoryUI.Parent.ToolDetails.Visible = true
			
		end
	end

end

while true do
	task.wait(1)
	itemDetails()
end

  1. What solutions have you tried so far?
    Generally it’s documentation and dev forum

Try changing isHovering to a local variable. Side note though calling that function in a loop will create a memory leak

isHovering is already as a local variable I forgot to add just in this article, I’m thinking about how to take itemButton out of this local function

Is playerInventory a frame or something? If so then you need to loop over its children (playerInventory:GetChildren()) not just playerInventory

You’re right that’s how it should be a silly mistake, but the code still doesn’t execute

Okay I already understand why it did not reproduce, sorry for the busy time

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