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

Why isn't FocusLost event not working when I press enter?

Hello everyone, I have code that will write out the text you put into one textbox into another.

I looked on the wiki about something I can use to detect when I press enter to lose focus on a textbox and I found TextBox.FocusLost.

On the wiki, it says that the first parameter is enterPressed, which is boolean to tell me if someone lost focus on a textbox by pressing enter.

When I try pressing enter on the textbox, it doesn't print anything and if I click off, the output says: "Player pressed Enum.KeyCode.Unknown", even though I pressed enter.

Does someone know how to fix this? Thanks!

Code:

local writeBox = script.Parent
local autoWriteBox = writeBox.Parent.AutoWriteBox

writeBox.FocusLost:Connect(function(enterPressed, inputThatCausedFocusLost)
	if enterPressed then
		print("Player pressed Enter")
		
	else
		
		print("Player pressed", inputThatCausedFocusLost.KeyCode)

	end
end)

2 answers

Question, I will edit this comment with the script if I get this. Are you using a local script or a server script?

2 comments

0

I solved this because my textbox was broken and I just made a new one and it works fine now.

0

Btw this was a local script.

I realized that my code wasn't the problem it was because my textbox was broken and all I had to do was make a new textbox.

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