Boolean for clickdetector hover

I know about MouseHoverEnter and MouseHoverLeave but is there a boolean that I can use to detect if a click detector is being hovered on?

I need a boolean because Im looping through all parts with clickdetectors inside them

If its possible to do this another way, Im fine with that.

1 Like

very poorly explained. My biggest question is why do you have more than 1 click detector in a single part?

1 Like

I would manually set the boolean value.

local isHovered = false

ClickDetector.MouseHoverEnter:Connect(function()
       isHovered = true
end)

ClickDetector.MouseHoverLeave:Connect(function()
       isHovered = false
end)

With that said, this is a sign of a deeper design flaw. I don’t recommend using multiple click detectors is a bad habit in one part.

2 Likes

Whoops I edited the OP

sorry about that

I dont have multiple click detectors just multiple parts with detectors

2 Likes

ok my next question. Why use click detectors to detect hovering?

1 Like

Is there another way thats better?

2 Likes

I would do what I showed you, but store it in a table.

You could do hoverTable[partName] = true/false

True = hovered
false = not hovered

1 Like

If you could explain to me the whole idea perhaps i could help. What exactly are you trying to make?
Then we can discuss how best to make it

1 Like

Here,

I have a tile-based game, and Im looping through the players tiles (The ones that you own and the ones That aren’t inside of battle fog) and seeing if they have a click detector.

If they do, Im assuming that that tile can be selected, but I want the tile to glow a bit when you hover over it.

Im using a click detector to detect the clicking and hovering, but if there is a better way that would be nice.

2 Likes

Whenever the mouse goes over the part you could set that part to neon or add a light to it.

2 Likes

My problem is that I cant detect when the mouse goes over the part

2 Likes

well if you have like a selection mode, then when this selection mode is on you can use Mouse.Target to figure out what part is being “selected” and then do stuff to it upon finding it.

In this example i am just changing the color of the part

https://streamable.com/gp55s1

game:GetService(“RunService”).RenderStepped:Connect(function()

Mouse.Target.BrickColor = BrickColor.new(“Baby blue”)

end)

Using this method you would also have to make sure to turn the back how they were when they are “unselected”

2 Likes

Is there A way To do this in a localscript?

I could use remote events just it would be a lot easier to do it straight up in the localscript

nevermind?
it is in a localscript

2 Likes

it should be done in local script because server script can’t get the players mouse

1 Like

umm, It says that the “mouse” object is nil, Is it a parent of something?

Tools wont work since the characterAutoLoads is off.

Now that I think about it CharacterAutoLoads could be on it just deletes the player

Nevermind I Think I got it

2 Likes

Okay I didnt realise I needed

local Mouse = game.Players.LocalPlayer:GetMouse()

to make it work

2 Likes