So I was making a part of a game where you could type in a textbox and if its correct it’ll print it.
Here’s my code:
script.Parent.FocusLost:Connect(function()
if script.Parent.Text == "test" then
print("Working")
else
error("Problem occured again.")
end
end)
When I put test into the textbox, it does the error I tried adding prints and it says that everything is correct the text is test and test = test so im not sure what the problem is, with knowing how to script, this is the weirdest thing I have seen. Thanks!
By the way I looked on google and found no similar problems.
Found the problem (maybe), there was a report in #platform-feedback:engine-bugs that there is a carriage when you press enter in the textbox. Link is here:
Perhaps this is related to the recent Roblox bug? Have you tried setting anything up to remove the special control character (which’s what the bug is)?
I think I might have a solution to this problem, since the %c check didn’t work.
local ContainsControlCharacter = script.Parent.Text:gsub("%w", ""):gsub("%p", "") ~= "";
What this essentially does is remove any letters, numbers and punctuation, and compares the result to an empty string; if the string isn’t empty, it has the control character, thus returning true. If not, it’ll return false.
For use in your code, the following could be tried
local Input = script.Parent.Text;
local ControlCharacterCheck = Input:gsub("%w", ""):gsub("%p", "");
if (ControlCharacterCheck ~= "") then
Input = Input:gsub(ControlCharacterCheck, "");
end
print(Input == "test");
It’s a long shot, and I might be overcomplicating this, but I think it’s worth a try.
I hope this helped.
Edit
You’re very much welcome! I’m so glad this solution worked.