#trying to detect if player is in a textbox and pressed enter.

28 messages · Page 1 of 1 (latest)

distant thunder
#

the enter key works but i cant seem to get the script to detect if the textbox is focused or not. tysm!

script:

local uis = game:GetService("UserInputService")


uis.InputBegan:Connect(function(inp, chat)
    if chat then return end


    if game.StarterGui.TextBox:IsFocused() and inp.KeyCode == Enum.KeyCode.Return then
        print("enter was pressed and the text box is focused")
    end
end)
young field
#

:Focused

#

and thats not how u do it btw

distant thunder
#

oh mb

young field
#
TextBox.FocusLost:Connect(function(enterPressed)
    if enterPressed then
        print("Enter was pressed")
    end
end
distant thunder
#

oh shit thats it?

young field
#

yes

young field
#

u shouldnt refer to uis that are in StarterGui

#

your uis

#

are in player.PlayerGui

distant thunder
#

also tysm 4 ur help

young field
#

StarterGui gets replicated as "PlayerGui" inside a player

#

think of it as a sample i guess

#

or a template

#

@distant thunder

distant thunder
#

i know what u mean now

#

yeah i ran into that problem last week

young field
#

same with StarterPack

distant thunder
#

now i udnerstand

young field
#

it becomes Backpack

distant thunder
#

the game.players.playergui

#

yes mb!

#

tysm!

young field
#

np