Hello! I am coding a shop gui for an upcoming new game and am working on a gui that follows the mouse whenever it enters a button. It works perfectly, but I am having an issue where two functions override each other and the gui ends up not being visible whenever I move my mouse too fast. My video here will show what I mean.
Here is the code. Any ideas or help is greatly appreciated
local Mouse = game.Players.LocalPlayer:GetMouse()
local MouseFrame = script.Parent.MouseFrame
local uis = game:GetService("UserInputService")
MouseFrame.Visible = false
Mouse.Move:Connect(function()
MouseFrame.Position = UDim2.new(0, Mouse.X + 10, 0, Mouse.Y + 35)
end)
Style1.MouseEnter:Connect(function()
MouseFrame.Visible = true
MouseFrame.Product.Text = "Test Name!"
MouseFrame.Desc.Text = "Testing..."
MouseFrame.Robux.Text = "100 Robux"
end)
Style1.MouseLeave:Connect(function() -- This is where the problem starts
MouseFrame.Visible = false
end)
Style2.MouseEnter:Connect(function()
MouseFrame.Visible = true
MouseFrame.Product.Text = "Testing 2"
MouseFrame.Desc.Text = "Test #2"
MouseFrame.Robux.Text = "30 Robux"
end)
Style2.MouseLeave:Connect(function()
MouseFrame.Visible = false
end)
So your problem is that the already visible frame is going visible then invisible. It should go from visible, to invisible, back to visible. Your MouseEnter functions should check if the MouseFrame is invisible. If it is invisible, then make it visible. If itās visible, then wait until the MouseLeave function has fired then make it visible again. Just an idea, not sure if itāll work.
I canāt really because Iām on phone, I mean if you had a variable that turns on when your mouse hovers over one of the guis, and while the variable is āonā (equals true or whatever), it wonāt show you info to a different gui, and then when your mouse leaves the first gui the variable will turn off again (become false). This will stop the overlapping problem
You can wait for an event with :Wait(), however you have many different mouse leave events, so Iām not exactly sure how that would work.
Youād have a better chance with using a loop or something.
Style1.MouseEnter:Connect(function()
if MouseFrame.Visible == true then
repeat task.wait() until MouseFrame.Visible == false
end
MouseFrame.Visible = true
MouseFrame.Product.Text = "Test Name!"
MouseFrame.Desc.Text = "Testing..."
MouseFrame.Robux.Text = "100 Robux"
end)
Using an if statement might make things even worse, but the MouseFrame should always be invisible if you are entering. If it is visible when entering, then you wait for whatever mouse leave function hasnāt fired yet.