If statement not working

For some reason it some how ignores:

v.Name ~= "UIGridLayout"

When it should not. I have a list of items, and one of them is called “UIGridLayout”

if (v.Name ~= SlotOneWeapon or v.Name ~= SlotTwoWeapon or v.Name ~= SlotThreeWeapon or v.Name ~= "UIGridLayout") then

That’s the if statement.

1 Like

We need to see the rest of the script to see how it relates to how you save “UIGridLayout”

Do and instead of or. There’s no way it can be named all those things at once, so using or is just useless.

4 Likes

Is it because you have “UIGridLayout” in quotes?

That’s a string, it’s a valid comparison so no.

Like ScriptingSausage said, remember “or” will be true if either condition is true but “and” is only true if both conditions are true.

But since we can’t see the script, is it supposed to be a variable?

It’s checking the name of something, which is always a string.

Yup, names are a string. It’s not a variable

2 Likes

It could be a variable if it contains a string but I don’t think that’s the case here.

It’s not a variable here though, not in my game. It’s an actual object.

1 Like