Weird Behaviour on MouseEnter event on Imagelabel

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to have a for loop that detects if any of my imagebuttons have been hovered by the
    mouse or not.
  2. What is the issue? Include screenshots / videos if possible!
    For some reason when I hover the first imagebutton on my UIGridLayout it decides to execute
    the event for all imagebuttons under that frame or affected by UIGridLayout.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I’m honestly completely lost and thought I made some easy mistake somewhere but apparently not.

This is my current script:

for i,v in pairs(SelectFrame:GetDescendants()) do
	if v:IsA("ImageButton") then
		v.MouseEnter:Connect(function()
			print("gg")
			
			print(v)
			
			local ButtonClone = v:Clone()
			ButtonClone.Position = UDim2.new(0,v.AbsolutePosition.X,0,v.AbsolutePosition.Y + 37)
			ButtonClone.Size = UDim2.new(0,v.AbsoluteSize.X,0,v.AbsoluteSize.Y)
			ButtonClone.Parent = script.Parent.SelectedButton
			
			v.Visible = false
		end)
	end
end
1 Like

I think I understand why now after posting this. It’s because I turn the imagebutton invisible which makes the buttons move back along the UIGridLayout.

1 Like