How to disable text box in first person

I would like to disable the text box by detecting the return key however the return key adds another line in the text box.

Hmmm… Try using this script below. If it doesn’t work, let me know :slight_smile:

textbox.FocusLost:Connect(function()
     textbox.Visible = false
end)

It doesn’t seem to work in the way I used it (I just inserted the code and pressed enter)

Can you show me the full code including the code I told you to insert? Also, try stopping and running the project again to make sure it is updated.

function OpenChant()
	CAS:UnbindAction("open")
	DOFAppear:Play()
	Box.Visible = true
	Box:CaptureFocus()
end


Box.FocusLost:Connect(function()
	Box.Visible = false
end)

CAS:BindAction("open",OpenChant,true,Enum.KeyCode.T)

Also what would FocusLost really do?

Ok. Another solution is to use UserInputService. I believe it still fires when in a textbox, so just use this code and delete the last piece you inserted.

game:GetService('UserInputService').InputBegan:Connect(function(key)
     if key.KeyCode == Enum.KeyCode.Return then 
          Box.Visible = false
     end
end)

Also, FocusLost normally detects when a user stops editing the textbox, basically. Normally it should fire when Enter is pressed, so IDK whath happened. :slight_smile:

Ah thanks this seems to work! (30)

No problem! Glad it helped :smiley: