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

What does the "~" symbol do?

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?

1 comment

0

I think it equals nil

1 answer

✓ Accepted answer

~ 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!

2 comments

0

So using ~ means anything besides that number?

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!

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