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

shortcut type in text not working properly, help?

if you type in "h", "hi" it will print noob, if you type in "l" "lo" or "lol", it will print idiot, it doesn't work; please help

Here's the script:

script.Parent.BackGround3.Enter.MouseButton1Click:connect( function()
local Order1 = script.Parent.BackGround3.Order1Handler
local noob = {"h", "hi"}
local idiot = {"l", "lo", "lol"}
	
	if Order1.Text == noob[1 or 2] then
	print("noob")
	elseif Order1.Text == idiot[1 or 2 or 3] then
		print("idiot")
   
end
end)

2 answers

✓ Accepted answer

Use if (statement) == (table)[1] or (statement) == (table)[2] then; you can continue it since [1 or 2 or 3] is NOT correct, try this

script.Parent.BackGround3.Enter.MouseButton1Click:connect( function()
local Order1 = script.Parent.BackGround3.Order1Handler
local noob = {"h", "hi"}
local idiot = {"l", "lo", "lol"}

    if Order1.Text == noob[1] or Order1.Text == noob[2] then
    print("noob")
    elseif Order1.Text == idiot[1] or Order1.Text == idiot[2] or Order1.Text == idiot[3] then
        print("idiot")
end

end)

If this helped mark this as the answer!

Hey. I think I see the issue, I am not sure if it will work though! When doing prints with shortcuts, you don't have to put the ""s. ` This script should work properly.

01 script.Parent.BackGround3.Enter.MouseButton1Click:connect( function() 02 local Order1 = script.Parent.BackGround3.Order1Handler 03 local noob = {"h", "hi"} 04 local idiot = {"l", "lo", "lol"} 05 06 if Order1.Text == noob[1 or 2] then 07 print(noob) 08 elseif Order1.Text == idiot[1 or 2 or 3] then 09 print(idiot) 10 11 end 12 end)

There is a chance that I have understood what you meant wrong, though. If so then let me know!

2 comments

0

Oh wait I pasted it wrong. I just realized that I pasted the code wrong, just dont put the ""s in the prints.

0

It's better if you made a code block. :eyes:

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