Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I get MouseHoverLeave to work?

I'm making a script that would make something appear on top of a brick when a mouse hovers over it, and disappear when the mouse stops.

However I am having problems with this

Here is my script:

script.Parent.Head.ClickDetector.MouseHoverLeave:connect(function(playerwhoclicked)
			if script.Parent:FindFirstChild(part.Object.Value) then
			wait(1)
			local ghostobjecty=script.Parent:FindFirstChild(part.Object.Value)
			ghostobjecty:Remove()
			end
		end)

This is what removes it However for some reason this script is triggered right after the MouseHoverEnter script, and I can't understand why it's not working. Please help.

1 answer

✓ Accepted answer

Your script will fire the moment a mouse has hovered a the Head and then leaves. You may want to use MouseHoverEnter and then MouseHoverLeave with eachother, as shown bellow. I changed playerwhoclicked because none of these events involve clicking.

local Head = script.Parent:WaitForChild("Head") -- Variable to shorten code

Head.ClickDetector.MouseHoverEnter:connect(function(PlrThatEntered) -- Not Clicking
	if script.Parent:FindFirstChild(part.Object.Value) then
        	wait(1)
         	local ghostobjecty = script.Parent:FindFirstChild(part.Object.Value)
	end
	Head.ClickDetector.MouseHoverLeave:connect(function(PlrThatLeft) 
            	ghostobjecty:Remove()
	end)
end)

You really don't need the parameters because you don't seem to be using them.

If this helped, accept the answer, otherwise comment any questions or problems you may have!

3 comments

0

The tabbing looks horrid, sorry'bout that

0

Im using the parameters for things outside of the script

0

They wont work outside of the scope of the event.

This discussion is preserved as it was. New answers, comments, and votes are closed.