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

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

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.

4 comments

0

Are you using a LocalScript?

0

Make sure you're using a LocalScript in your TextButton

0

The Only Problem. That Can Be Is That Your Not Using A LocalScript

0

MouseButton1Click is not a valid event of TextBox. It's reserved for buttons only i think

1 answer

✓ Accepted answer
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.

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