So I used this block of code, and it doesn't trigger when I press enter while editing a TextBox. I'm testing this in the actual game, not studio.
local function FocusLost(enterPressed)
if enterPressed then
-- stuff
end)
script.Parent.FocusLost:connect(FocusLost)

2 comments
Have you tried MouseButton1Down:connect(FocusLost)
TextBoxes don't even have a mousebuttondown, and No, that wouldn't work, I need the enter key to be pressed.