I have been trying to do it for so long but nothing is happening when I put in the text
if TextBox.Text == "H+MbQeTh" then print("hi") end
You will need to put the if statement inside an event or loop. Putting it inside a loop (such as a while loop
) means that it will loop indefinitely, therefore, constantly checking the condition of the if statement; this is not recommended as it will waste resources and will cause lag, especially since there are better ways to do this (such as using events). You can check what events are available for an object by searching for it in the Roblox documentation and navigating to events.
As you can see here, from the documentation, the TextBox has an event FocusLost
which will fire when the client clicks off the TextBox.
This event also has two parameters, the first being a boolean indicating whether the client pressed Enter to lose focus; the second parameter is the input object that caused the loss of focus.
TextBox.FocusLost:Connect(function(enterPressed, inputThatCausedFocusLoss) if TextBox.Text == "H+MbQeTh" then print("hi") end end)
If you want to check the condition of the if statement when the client types into the TextBox, you can use the GetPropertyChangedSignal
method which will return an event whenever the Text property changes.
TextBox:GetPropertyChangedSignal("Text"):Connect(function() if TextBox.Text == "H+MbQeTh" then print("hi") end end)