Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

enterPressed on TextBox's FocusLost not triggering?

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

0

Have you tried MouseButton1Down:connect(FocusLost)

0

TextBoxes don't even have a mousebuttondown, and No, that wouldn't work, I need the enter key to be pressed.

2 answers

✓ Accepted answer

It may be you forgot the 'end' to close the 'if then' statement.

local function FocusLost(enterPressed)
	if enterPressed then
		--stuff
	end -- You forgot this.
end)

script.Parent.FocusLost:Connect(FocusLost) -- They changed it so it's recommended to use ':Connect' instead of ':connect'.

I hope this helped.

3 comments

0

you use Connect(function() I think you made a mistake there, and the ) on the 2nd end. Thanks for the answer anyway, didn't work.

0

Found the issue, was a remoteevent issue

0

Oh I just realized I did that. FIxed it.

script.Parent.FocusLost:connect(function(enterPressed)
    if enterPressed then
   --stuff
    end
end)

2 comments

0

i hoped that this works for you.

0

Thanks for the answer anyway, I found the error in remote event naming. I had the 2 scripts on two different duplicate events.

This discussion is preserved as it was. New answers, comments, and votes are closed.