gui.InputBegan:Connect(function(inputObject)
if inputObject.UserInputType == Enum.UserInputType.MouseMovement then
-- Mouse entered
end
end)
gui.InputEnded:Connect(function(inputObject)
if inputObject.UserInputType == Enum.UserInputType.MouseMovement then
-- Mouse entered
end
end)
Note that this doesn’t handle touched inputs very nicely. I’m using this ButtonHighlightModel class to handle all of the input stuff in my game.
local model = maid:Add(ButtonHighlightModel.new(button)
maid:GiveTask(model.IsHighlighted:Observe():Subscribe(function(isHighlighted)
print("IsHighlighted", isHighlighted)
end))
-- Animation
maid:GiveTask(model:ObservePercentHighlight():Subscribe(function(percent)
button.UIScale.Scale = 1 + 0.1*percent
end))