Well, I'm just messing around on studio and I'm trying to have a brick change color randomly while a mouse is on it, and stay red while the mouse is not on it. I can easily have it change color, however, I able to loop the brick changing color while the mouse is on it, but not change back to red. Any thoughts, feedback, etc, would be helpful. Thanks. Edit: I realize now that the mousehover enter is an event and not a function and it only triggers a function. Anything I can use to make a while or if statement?
You would use the other ClickDetector event called MouseHoverLeave
I'm not so sure about whet you mean when you say that you are looping it. However, you would probably use this:
script.Parent.ClickDetector.MouseHoverEnter:Connect(function(player) script.Parent.BrickColor = BrickColor.new("Bright green") script.Parent.ClickDetector.MouseHoverLeave:Wait() script.Parent.BrickColor = BrickColor.new("Bright red") end)
If you want to make it so that it constantly changes color while your mouse is over it, then be red when the mouse leaves, here is what you do:
script.Parent.ClickDetector.MouseHoverEnter:Connect(function(player) local hover = true local connection = script.Parent.ClickDetector.MouseHoverLeave:Connect(function(player) hover = false end) while hover do wait(0.1) script.Parent.BrickColor = BrickColor.Random() end script.Parent.BrickColor = BrickColor.new("Bright red") end)