Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

1337 else not 1337 script, its simple??

Asked by
korj5 0
8 years ago

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"?

0
Ignore the line 9 please.. korj5 0 — 8y
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. M39a9am3R 3210 — 8y

1 answer

Log in to vote
2
Answered by
itsJooJoo 195
8 years ago

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)
0
Also make sure it's in a LocalScript. They power all GUIs itsJooJoo 195 — 8y
0
Its same thing, I'm trying >= instead ~= korj5 0 — 8y
0
>= means greater than. ~= means is not equal to. TheHospitalDev 1134 — 8y
0
Does it say anything in the Output? itsJooJoo 195 — 8y
Ad

Answer this question