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

What does the "~" symbol do?

Asked by 9 years ago

I was looking at some other scripts, and looked on the actual wiki, and didn't seem to find out what "~" meant. Can anyone help me answer this?

0
I think it equals nil TheHospitalDev 1134 — 9y

1 answer

Log in to vote
3
Answered by
Necrorave 560 Moderation Voter
9 years ago

~ is part of a conditional operator. It is also known as "Not"

Example of '~':

~= is like saying "Not equal"

if (x ~= 0) then --If x "Is NOT equal to" 0
    --Code
end

You can also use not in other parts of the conditional statement to determine if something is "Not".

Example of 'not':

if (not x) then --If NOT true, then
    --Code
end

Let me know if you have any other questions!

0
So using ~ means anything besides that number? JamesLWalker 297 — 9y
0
Yes, in a nutshell. Remember that `~` by itself is not enough. You need to have the full operator `~=` for it to detect if something not equal. You can also use it for strings or error checking! `x ~= nil` can check if something exists too! Necrorave 560 — 9y
Ad

Answer this question