I’m trying to make a script read what is in a text box, to activate or do a task.
For example, I type “add part” in a text box, press enter, and it puts a part (with specific properties like size, color, or material) in a specific location.
I haven’t found a way to do this though, and I’m posting here just to see if anyone knows an easy method for doing this.
2 Likes
Are you making a command system within the textbox? if so, you can probably check by seeing if the text and the string “add part” matches up.
1 Like
Initially, I thought of a script outside of the GUI, that checks what is entered in the text box, and if the text correlates with something in the script (checking for “add part” for example), then it goes to the script if it does.
1 Like
Why not make another UI textbutton that when pressed, can check whats entered in the textbox.
1 Like
Is it possible to make pressing the Enter key to check what’s entered?
(reason is so it doesn’t automatically execute a function when typing something)
for me i havent tried, i usually use a button to check whatever is in the textbox since its more easier, you can probably use the players inputs to check though.
I have this script I used a bit ago but doesn’t work.
local text = script.Parent
text.InputChanged:Connect(function()
local input = string.lower(tostring(text.Text))
if input == "hi" or input:find("hi") then
print("works")
end
end)
Pretty sure it’s supposed to find the text and check if it says “hi”, then print “works”, but it doesn’t print anything.
you could try finding a script that uses string.match. theres plenty of references on the devforum.
I attempted to use string.match in a way, didn’t work.
local text = script.Parent
text.InputChanged:Connect(function()
local input = string.lower(tostring(text.Text))
local match = string.match(input, "hi")
if match then
print("works")
end
end)
local thatthingyourtryingtofindinyourstring = "thisisthethingimtryingtofind"
if string.match("hi", thatthingyourtryingtofindinyourstring) then
print("i have found the thing i was trying to find in my string")
end
now obviously this wouldnt print anything because of the “thatthingyourtryingtofindinyourstring”'s string doesnt match with “hi”.
Doesn’t work
local text = script.Parent
text.InputChanged:Connect(function()
local input = text.Text
if string.match("hi", input) then
print("works")
end
end)
(not sure if I did this correctly)