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 4 years ago
script.Parent.ClickDetector.MouseHoverEnter:Connect(function(player) -- my script
local part = script.Parent      
repeat -- i want to make it so that if i hover on the part it will keep changing colors non stop 
while true do -- I wanted this to loop forever until i hovered out of the Part
for i= 0,1
do
    wait(0.5) -- controls interval between color change(so it changes color every half a second)
    part.BrickColor = BrickColor.Random() -- what i want to happen while im hovering on the part
end
 end      
until 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?
wait(2) 

part.BrickColor = BrickColor.new("White")   
end)    
end)

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