Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

enterPressed on TextBox's FocusLost not triggering?

Asked by
H4X0MSYT 536 Moderation Voter
8 years ago

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)
0
Have you tried MouseButton1Down:connect(FocusLost) LearnBeginnersLua -2 — 8y
0
TextBoxes don't even have a mousebuttondown, and No, that wouldn't work, I need the enter key to be pressed. H4X0MSYT 536 — 8y

2 answers

Log in to vote
0
Answered by
Master_JJ 229 Moderation Voter
8 years ago
Edited 8 years ago

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.

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. H4X0MSYT 536 — 8y
0
Found the issue, was a remoteevent issue H4X0MSYT 536 — 8y
0
Oh I just realized I did that. FIxed it. Master_JJ 229 — 8y
Ad
Log in to vote
0
Answered by 8 years ago
script.Parent.FocusLost:connect(function(enterPressed)
    if enterPressed then
   --stuff
    end
end)
0
i hoped that this works for you. LearnBeginnersLua -2 — 8y
0
Thanks for the answer anyway, I found the error in remote event naming. I had the 2 scripts on two different duplicate events. H4X0MSYT 536 — 8y

Answer this question