Door = game.Workspace.Wall function pie() if Door.Transparency == 1 then Door.Transparency = 0 else Door.Transparency = 1 end end script.Parent.ClickDetector.MouseClick:Connect(pie)
"if Door.Transparency == 1 then"
Why not just "="?
=
and ==
are two different operators and do different things. The former assigns a variable or table field to a value. The latter compares two given values, and returns true
if they are raw equal, or equal via __eq
.
Plus it could be ambiguous, do you want to assign Transparency
to 1
or compare it to 1
?
Code language creators wanted to have a difference between the two since it would confuse the computer. We use = for assigning a value, and == for comparing a variable.
Well i see a lot of people has already answered this question but i don't see any quick and short explanation so here:
Basically =
is used for setting something example as:
game.workspace.part.Name = "test" or game.workspace.part.Parent = game.ReplicatedStorage or *game.Players.Zetruis.Leaderstats.Money.Value = 1000"
and the list goes on.
The ==
is used to define is something equals to something example as:
if game.Players.Zetruis.Name == "Zetruis" then print"okay its him" end or if (5+10) == 15 then print"ok" end
and of course the list goes on.