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

What is the difference between "=" and this "==" And does spaces matter?and other multiple question.

what is the difference between one "=" and two "=". Do spaces matter in LUA coding? and last question. What does plr:LoadCharacter() mean, what does the two empty brackets do?

1 comment

0

LoadCharacter() is an internal method to load the players character, the empty parenthesis call the method. Methods are basically just functions with the object sent as the argument. Emily explained the rest.

5 answers

✓ Accepted answer

I know other people have answered most of these questions, but I'll try to give a more descriptive answer. If you use =, you're setting something to a value, like a variable. For example:

testVariable = 1
--This sets the variable (testVariable) to 1.

Use == if you're comparing two values. For example:

if testVariable == 1 then
print("Hello!")
end

Basically, we're seeing if testVariable is 1. If it is, then the output is "Hello!"

Okay another question. Do spaces matter in Lua? Most of the time, no. For example, it doesn't matter if you do this:

testVariable = 1

or this:

testVariable=1

But if you're trying to specify a part or something else:

--Let's say the name of the part is TestPart.
game.Workspace.TestPart.CanCollide = false
--This is valid

game.Workspace.Test Part.CanCollide = false
--This is invalid, because the game thinks the part it's looking for is called "Test Part", but that is non-existent.

Hope this helps, and happy coding!

2 comments

1

Thanks :D this actually helps!

0

Happy to help!

Single = is an assignment to a variable (variable on the left, expression on the right)

Double == is the equality comparison operator, (a==b) evaluates to true or false.

You can't have spaces between the characters in ==, it will not be interpreted correctly.

1 comment

0

good job you deserve upvotes you got

"=" Is used to assign a value to something while "==" is used for comparing.

"==" is for checking something. "=" is for declaring something.

MyVariable = "Hello"

if MyVariable == "Hello" then
   print("Your Variable is the same as "Hello".)
end

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