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.
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!