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

if statement with and doesn't work but a normal if statement does?

Asked by 3 years ago
Edited 3 years ago

So as you can see by the title I don't know how to explain this, but if I put an if statement like this: if NextFoV == 0 then this works, but if I have this: if NextFoV >= 0 and NextFoV <= 121 then, I can enter in any FoV number and the error catching system won't do it's thing. Thanks!

Addendum; Full code is

if tonumber(InputBox.Text) then

    NextFoV = tonumber(InputBox.Text)
    -- // Run if ConfirmButton is pressed. \\ --
    if NextFoV >= 0 and NextFoV <= 121 then
        -- // Check if input is fully numerical. \\ --

        -- stuff
    else
        -- // If input is not fully numerical, run this. \\ --
        Err()
        end
    else
        Err()
    end
end)
0
It works just fine?? Ziffixture 6913 — 3y
0
I'm assuming it's something else in the code that's messing it up then, I just added the entire part of the script so you can diagnose what's going on better VoidKeyword 111 — 3y
0
nevermind, not sure why but 0 just seemed to break it VoidKeyword 111 — 3y
0
^ due to me adding an = so instead it would be >= so yeah I'm stupid VoidKeyword 111 — 3y
0
Try math.clamp instead. I also have something similar to what you're trying to achieve on this post https://scriptinghelpers.org/questions/99315/how-do-i-change-a-players-fov-field-of-view uhi_o 417 — 3y

Answer this question