Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

why wont my hover function stop?

Asked by 5 years ago
01script.Parent.ClickDetector.MouseHoverEnter:Connect(function(player) -- my script
02local part = script.Parent     
03repeat -- i want to make it so that if i hover on the part it will keep changing colors non stop
04while true do -- I wanted this to loop forever until i hovered out of the Part
05for i= 0,1
06do
07    wait(0.5) -- controls interval between color change(so it changes color every half a second)
08    part.BrickColor = BrickColor.Random() -- what i want to happen while im hovering on the part
09end
10 end     
11until part.ClickDetector.MouseHoverLeave:Connect(function(player) -- I do not know why,But when I stop hovering over it it just keeps going can someone explain why?
12wait(2)
13 
14part.BrickColor = BrickColor.new("White")  
15end)   
16end)

this is my script and my main problem is that when my cursor leaves the Part it doesn't stop and it just keeps going

Answer this question