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

I want to check if the text in textbox is equal to my text. Can you help me?

Asked by 4 years ago
Edited 4 years ago

Hello, I need help with this script, Why is it not working? I would like to have a text output if the text in the text box is "12345".

Here is my script:

local TextBox = script.Parent.Parent.Parent.TextBox

script.Parent.MouseButton1Click:Connect(function()
if TextBox.Text == "12345" then
    print("Code accepted")
end
end)

Thanks for your help.

0
Are you using a LocalScript? Ziffixture 6913 — 4y
0
Make sure you're using a LocalScript in your TextButton AntoninFearless 622 — 4y
0
The Only Problem. That Can Be Is That Your Not Using A LocalScript CallMe_Axis 63 — 4y
0
MouseButton1Click is not a valid event of TextBox. It's reserved for buttons only i think iNot_here 93 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
local TextBox = script.Parent.Parent.TextBox
script.Parent.FocusLost:Connect(function()
    if TextBox.Text == "12345" then
        print("Code accepted")
    end
end)

FocusLost fires whenever a player presses enter, clicks out of the text box, or anything that would stop the player from typing into the text box.

Ad

Answer this question