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

How do you make something happen if your mouse hovers over an object?

Asked by
Astilev 30
9 years ago

Let's say my mouse hovers over a block, how do I make the size increase, and decrease back after my mouse moves away from it?

1 answer

Log in to vote
3
Answered by
GShocked 150
9 years ago

http://wiki.roblox.com/index.php?title=API:Class/ClickDetector

It details MouseHoverEnter and MouseHoverLeave as children of ClickDetector

p = Instance.new('Part', game.Workspace)
c = Instance.new('ClickDetector', p)
script.Parent = p

script.Parent.ClickDetector.MouseHoverEnter:connect(function()
   p.Size = Vector3.new(p.Size.X*2,p.Size.Y*2,p.Size.Z*2)
end)

script.Parent.ClickDetector.MouseHoverLeave:connect(function()
   p.Size = Vector3.new(p.Size.X/2,p.Size.Y/2,p.Size.Z/2)
end)

That should double the size when mouse hover enters, and go back to normal when it leaves.

Ad

Answer this question