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

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

Asked by 4 years ago

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?

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. Azarth 3141 — 4y

5 answers

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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!

1
Thanks :D this actually helps! clawcollection10 3 — 4y
0
Happy to help! blarp_blurp645 63 — 4y
Ad
Log in to vote
8
Answered by 4 years ago

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.

0
good job you deserve upvotes you got programmerHere 371 — 4y
Log in to vote
0
Answered by 4 years ago

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

Log in to vote
0
Answered by 4 years ago

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

MyVariable = "Hello"

if MyVariable == "Hello" then
   print("Your Variable is the same as "Hello".)
end
Log in to vote
-4
Answered by 4 years ago

= means equals == means equals to

0
very descriptive... I see TheRealPotatoChips 793 — 4y

Answer this question