Basically what i want to do is when my mouse is hovering over a TextButton i can press a key and it'll detect it. How would i go about doing this? Heres the code i wrote but it doesn't work:
button.MouseMoved:Connect(function() mouse.KeyDown:Connect(function(input) print(input) if input.KeyCode==Enum.KeyCode['F'] and button.favorite.Visible==false then button.favorite.Visible=true else button.favorite.Visible=false end end) end)
So event listeners like Hover and KeyDown activate no matter where they are when you hit the key. So you need to put a debounce. Which is a fancy way of saying make a bool variable = true when you are hovering and only run the code inside KeyDown when it’s true. Also I believe there is a mouseHover event you can use instead of MouseMoved. Not sure but you can look into that.
local variableName = false button.MouseMoved:Connect(function() variableName = true mouse.KeyDown:Connect(function(input) if variableName then print(input) if input.KeyCode==Enum.KeyCode['F'] and button.favorite.Visible==false then button.favorite.Visible=true else button.favorite.Visible=false end variableName = false end end) end)