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

How do I make a textLabel when users type into TextBox?

I have a searchbar which is a Textbox and I want to make it so if users type for example spiderman90438 into it than textLabel will say something, Kinda like this:

if Type.Text == "spiderman90438"
	then textone.Text = "spiderman90438 is the owner of Roogle"
end

To help you textone is the textLabel and Type is the Searchbar, When I did it, It didn't work so I assume there is a different code for if the string of Type is spiderman90438 than the text changes, But what is the code?

4 comments

0

textbox.Changed:connect(function(Type)

0

Your comment does not help me in anyway because I don't know how I would use that piece of coding.

0

That's why you use the wiki.

0

I am looking right now and I don't see anything, Do you have the link to this "wiki" page?

2 answers

✓ Accepted answer

Answer 2 for the comment on the first one

You must edit your code, and have a string stored somewhere with the information.

NewInformation = "XYZ"
Type.FocusLost:connect(function()
    local text = Type.Text
    textone.Text =  NewInformation
end)

If you need more search functions, add an if function.

Type.FocusLost:connect(function ()
	local text = Type.Text
	if textt == "SquirreIOnToast" then
		textone.Text = "SquirreIOnToast is xyz"
	elseif text == "spiderman90438" then
		textone.Text = "spiderman90438"
	elseif text == "Puppies" then
		textone.Text = "Puppies are cute."  --Etc. Keep doing this until you end up with your desired result. 
	end
end)

If you wish for further reading on how to make a text-finding search engine, I suggest the three pages:

http://wiki.roblox.com/index.php?title=Table

http://wiki.roblox.com/index.php?title=Global_namespace/String_manipulation&redirect=no

http://wiki.roblox.com/index.php?title=Loops

It should be fairly easy to teach yourself using those resources if you want to expand on this project.

Use the following function here:

Step 1:

Use the FocusLost event

Type.FocusLost:connect(function()
	-- Rest of function goes here
end)

Then combine the second part:

Type.FocusLost:connect(function()
	local text = Type.Text
	textone.Text = text .. " is the owner of Roogle"
end)

And that should work!

Find the wiki here

Hope this helps!

3 comments

0

Oh and, if you wanted your 'if' statement, just use the code you put in your question and place it in the ' Rest of function goes here ' area.

0

How do I make it so if the user types "Dunkin Donuts" it will show different text and not just "Dunkin Donuts is the owner of roogle"

0

Change the string in line 3 to what you want. If you want it so it depends on what you type, add an if statement.

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