So this script makes the cursor (on hover) show a gui displaying the name of the item next to the cursor.
For some reason, every time i move the cursor just a little on the brick again, it will do the fading process AGAIN.
repeat wait() until game:GetService("Players").LocalPlayer local found = game.Players.LocalPlayer:FindFirstChild("PlayerGui") local gui = found:FindFirstChild("HoverGui") game.Workspace.hover.ClickDetector.MouseHoverEnter:connect(function() gui.HoverFrame.Label.Text = "Brick" for i=1,0,-0.05 do gui.HoverFrame.Label.TextTransparency = i gui.HoverFrame.Label.BackgroundTransparency = i wait() end script.Disabled = true end) game.Workspace.hover.ClickDetector.MouseHoverLeave:connect(function() for i=0,1,0.05 do gui.HoverFrame.Label.TextTransparency = i gui.HoverFrame.Label.BackgroundTransparency = i wait() end end)
I want the fading process to happen once only and it can be activated again after the mouse leaves from the brick.
Here is another method:
repeat wait() until game:GetService("Players").LocalPlayer local found = game.Players.LocalPlayer:FindFirstChild("PlayerGui") local gui = found:FindFirstChild("HoverGui") local MouseHoverEnterEvent function MouseIn() MouseHoverEnterEvent:Disconnect() -- Disconnects the Event, so MouseHoverEnter won't be activated unless it's reconnected. gui.HoverFrame.Label.Text = "Brick" for i=1,0,-0.05 do gui.HoverFrame.Label.TextTransparency = i gui.HoverFrame.Label.BackgroundTransparency = i wait() end end game.Workspace.hover.ClickDetector.MouseHoverLeave:connect(function() for i=0,1,0.05 do gui.HoverFrame.Label.TextTransparency = i gui.HoverFrame.Label.BackgroundTransparency = i wait() end MouseHoverEnterEvent = game.Workspace.hover.ClickDetector.MouseHoverEnter:connect(MouseIn())-- Reconnects the MouseHoverEnter end) MouseHoverEnterEvent = game.Workspace.hover.ClickDetector.MouseHoverEnter:connect(MouseIn()) -- Makes the initial connection with MouseHoverEnter
There is no requirement to disable the script unless your trying to do something else. What you needed was debounce. The script below is ready to use, please let me know if this answers your question.
repeat wait() until game:GetService("Players").LocalPlayer local found = game.Players.LocalPlayer:FindFirstChild("PlayerGui") local gui = found:FindFirstChild("HoverGui") on = false game.Workspace.hover.ClickDetector.MouseHoverEnter:connect(function() gui.HoverFrame.Label.Text = "Brick" for i=1,0,-0.05 do gui.HoverFrame.Label.TextTransparency = i gui.HoverFrame.Label.BackgroundTransparency = i on = true wait() end end) game.Workspace.hover.ClickDetector.MouseHoverLeave:connect(function() for i=0,1,0.05 do on = false gui.HoverFrame.Label.TextTransparency = i gui.HoverFrame.Label.BackgroundTransparency = i wait() end end)
try this
repeat wait() until game:GetService("Players").LocalPlayer local found = game.Players.LocalPlayer:FindFirstChild("PlayerGui") local gui = found:FindFirstChild("HoverGui") game.Workspace.hover.ClickDetector.MouseHoverEnter:connect(function() gui.HoverFrame.Label.Text = "Brick" for i=1,0,-0.05 do gui.HoverFrame.Label.TextTransparency = i gui.HoverFrame.Label.BackgroundTransparency = i wait(9999999999999999999999) end script.Disabled = true end) game.Workspace.hover.ClickDetector.MouseHoverLeave:connect(function() for i=0,1,0.05 do gui.HoverFrame.Label.TextTransparency = i gui.HoverFrame.Label.BackgroundTransparency = i wait(9999999999999999999999) end end)