Surface gui isn't capturing keyboard input

So I want to make buttons on surface gui to capture keyboard input so the players don’t have to click but rather press E to interact

The issue is that buttons on surface guis doesn’t capture keyboard input but if the button is parented to a screen gui then the said button captures keyboard inputs

I’ve tried to look around on the forums n stuff but couldn’t really find anything. I did find like 2 posts that were similar to my problem but they were from 2016 - 2018 with no solutions

This is the script I used for getting the input



Try using a detector for when the mouse is hovering over your gui and the desired key is pressed.

I had the same problem with a BillboardGui at one point because LocalScripts don’t work in the workspace. You can still parent the button to the SurfaceGui but put the LocalScript in the StarterGui instead. That approach worked for me, but I had to add an additional check to make sure the player was actually close to the object. Hope this helps!