Popup sometimes doesn't appear when hover

I want a little popup to appear when you hover over a warning symbol, but sometimes it doesn’t appear

task.wait(3)

for _,v in pairs(script.Parent.Parent.Materials:GetChildren()) do
	if v:IsA("Frame") and v:FindFirstChild("Warning") then
		v.Warning.MouseLeave:Connect(function()
			script.Parent.Visible = false
		end)
		v.Warning.MouseEnter:Connect(function()
			task.wait()
			script.Parent.Visible = true
		end)
	end
end

The task.wait() helped it not happen all the time but it still happens

It is because one button is trying to disable it while the other ks trying to enable it; consider making a state for each button; hovering

If all states are false; make it invisible, if one or more states are true; make it visible

For example


task.wait(3)

local States: {boolean} = {}

for Key: number, Value: Instance in pairs(script.Parent.Parent.Materials:GetChildren()) do
  if Value:IsA("Frame") and Value:FindFirstChild("Warning") then
    States[Key] = false
    v.Warning.MouseLeave:Connect(function()
      States[Key] = false
      script.Parent.Visible = table.find(States, true) and true or false
    end)
    v.Warning.MouseEnter:Connect(function()
      States[Key] = true
      script.Parent.Visible = table.find(States, true) and true or false
    end)
  end
end

Another simpler solution:

task.wait(3)

for _,v in pairs(script.Parent.Parent.Materials:GetChildren()) do
	if v:IsA("Frame") and v:FindFirstChild("Warning") then
		v.Warning.MouseLeave:Connect(function()
			script.Parent.Visible = false
		end)
		v.Warning.MouseEnter:Connect(function()
			script.Parent.Visible = true
		end)
		v.Warning.MouseMove:Connect(function()
			if not script.Parent.Visible then
				script.Parent.Visible = true
			end
		end)
	end
end

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