while true do local function onHoverEnter(player) script.Parent.Transparency = 0 end local function onHoverLeave(player) script.Parent.Transparency = 1 end ClickDetector.MouseHoverEnter:connect(onHoverEnter) ClickDetector.MouseHoverLeave:connect(onHoverLeave)
So i've formatted the script it into a code block for anyone who wants to answer.
while true do local function onHoverEnter(player) script.Parent.Transparency = 0 end local function onHoverLeave(player) script.Parent.Transparency = 1 end ClickDetector.MouseHoverEnter:connect(onHoverEnter) ClickDetector.MouseHoverLeave:connect(onHoverLeave)
But here's my answer.. Basically you want to show the part when the mouse hovers over it, then make it invisible as it leaves. Sounds simple enough.
As far as i'm aware your script is pretty much spot on but it's missing some stuff.
while wait() do local function onHoverEnter(player) script.Parent.Transparency = 0 end local function onHoverLeave(player) script.Parent.Transparency = 1 end ClickDetector.MouseHoverEnter:connect(onHoverEnter) ClickDetector.MouseHoverLeave:connect(onHoverLeave) end
All i've done is put an end on the loop to mark the end of the loop (pretty self explanatory). I also changed while true do to while wait() do to avoid crashing.
The loop itself isn't necessary and can be removed if you wish, i dunno what you plan to do with it but the current script will run just fine without it
(if you do remove the loop remember to remove the end at the bottom as well)
Anyway hope this helped :D
You don't need while loop to check the event is fire or not, because event( MouseHoverEnter
, MouseHoverLeave
) can fire again:
local function onHoverEnter(player) script.Parent.Transparency = 0 end local function onHoverLeave(player) script.Parent.Transparency = 1 end ClickDetector.MouseHoverEnter:connect(onHoverEnter) ClickDetector.MouseHoverLeave:connect(onHoverLeave)