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

1337 else not 1337 script, its simple??

I'm learning script, kind of having trouble with this script. I believe I'm doing wrong...

function codeentry()
	if script.Parent.Parent.Code.Text == "1337" then
		script.Parent.Parent.Code.Text = "Correct"	
wait(2)
	script.Parent.Parent.Parent.Parent.Frame:TweenPosition(UDim2.new(-0.5, 0, 0.25, 0), "Out", "Elastic", 2.5)
	else	
	if script.Parent.Parent.Code.Text == not "1337" then
		script.Parent.Parent.Code.Text = "Incorrect"
	script.Parent.Parent.Parent.Parent.Frame:TweenPosition(UDim2.new(-0.5, 0, 0.25, 0), "Out", "Elastic", 2.5)
	end
	end
end



script.Parent.MouseButton1Up:connect(codeentry)

I'm trying to make the text to say incorrect when you enter code that is not "1337"?

2 comments

0

Ignore the line 9 please..

0

Why not just remove the second if then statement? If the code is not 1337, there's no point in comparing what already is not 1337 to something else. Also, if you're going to use the not keyword, use it on an entire condition. Because not 1337 will not work.

1 answer

✓ Accepted answer

The term "== not 1337" doesn't seem like it would work. I suggest "~= 1337". Also, you're using else, then if, so the ~= 1337 doesn't even apply to this. Here is a fixed version (a least, I think it's fixed.):

function codeentry()
    if script.Parent.Parent.Code.Text == "1337" then
        script.Parent.Parent.Code.Text = "Correct"  
wait(2)
    script.Parent.Parent.Parent.Parent.Frame:TweenPosition(UDim2.new(-0.5, 0, 0.25, 0), "Out", "Elastic", 2.5)
    else --This says if it's anything besides 1337, then do the following
        script.Parent.Parent.Code.Text = "Incorrect"
    script.Parent.Parent.Parent.Parent.Frame:TweenPosition(UDim2.new(-0.5, 0, 0.25, 0), "Out", "Elastic", 2.5)
    	end
    end
end

script.Parent.MouseButton1Up:connect(codeentry)

4 comments

0

Also make sure it's in a LocalScript. They power all GUIs

0

Its same thing, I'm trying >= instead ~=

0

= means greater than. ~= means is not equal to.

0

Does it say anything in the Output?

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