generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Difference between '=' and '=='

Previous Thread :: Next Thread 
Shadowknight619 is not online. Shadowknight619
Joined: 28 Sep 2010
Total Posts: 2453
27 Jun 2012 01:26 PM
What's the difference?
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
27 Jun 2012 01:27 PM
Basically:

= Used for setting

== Used for comparing

> † KMXD †
Report Abuse
Shadowknight619 is not online. Shadowknight619
Joined: 28 Sep 2010
Total Posts: 2453
27 Jun 2012 01:29 PM
Why is it used in this script? I did the script myself, but just did the == because I saw it in a different script and that one worked.

function OnClicked()

if script.Parent.Transparency == 0 then
script.Parent.Transparency = 1
elseif script.Parent.Transparency == 1 then
script.Parent.Transparency == 0

end

script.Parent.ClickDetector.MouseClick:connect(OnClicked)
Report Abuse
WhoBloxedWho is not online. WhoBloxedWho
Joined: 25 Mar 2009
Total Posts: 4611
27 Jun 2012 01:30 PM
'=' is used to set a value to something

Cat = game.Workspace.Cat
Size = Vector3.new(1,1.2,1)
player = game.Players.LocalPlayer


'==' is used for comparing things, used in a few places.

if 2+2 == 4 then
print("It worked!")
end

while script.Name == "script" do
print("It worked!")
end


a = 1
repeat
wait(1)
a = a + 1
until a == 10
print("a is equal to 10 now")

The opposite of '=='(equal to) would be '~='(not equal to).
Report Abuse
Woodstauk4 is not online. Woodstauk4
Joined: 27 Dec 2010
Total Posts: 3061
27 Jun 2012 01:32 PM
when you use '==' you are comparing objects, while just one '=' changes an object.

In your script,
You used the '==' sign in an if then statement. That's because you're comparing the objects to determine whether or not the Transparency is whatever

Then, you should use a single '=' to change that transparency to a new value
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
27 Jun 2012 01:34 PM
Exactly;

function OnClicked()
if script.Parent.Transparency == 0 then --compares the script's parent's Transparency and 0
script.Parent.Transparency = 1 --set's it to 0
elseif script.Parent.Transparency == 1 then --compares it to 1
script.Parent.Transparency = 0 --sets it to 0
end
script.Parent.ClickDetector.MouseClick:connect(OnClicked)

> † KMXD †
Report Abuse
Shadowknight619 is not online. Shadowknight619
Joined: 28 Sep 2010
Total Posts: 2453
27 Jun 2012 01:34 PM
Ok, well the script I put up did not work. The output printed:

Workspace.Model.Model.Bonnet.Script:6: '=' expected near '=='

What did I do wrong?
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
27 Jun 2012 01:34 PM
^Also, that one needs an end .

> † KMXD †
 
Report Abuse
Woodstauk4 is not online. Woodstauk4
Joined: 27 Dec 2010
Total Posts: 3061
27 Jun 2012 01:35 PM
You accidently wrote
script.Parent.Transparency==1, it should be script.Parent.Transparency=1 since you're trying to change that value
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
27 Jun 2012 01:36 PM
You accidentally used two for setting the last one, and forgot an end.

    function OnClicked()
    if script.Parent.Transparency == 0 then --compares the script's parent's Transparency and 0
    script.Parent.Transparency = 1 --set's it to 0
    elseif script.Parent.Transparency == 1 then --compares it to 1
    script.Parent.Transparency = 0 --sets it to 0
    end
    end
    script.Parent.ClickDetector.MouseClick:connect(OnClicked)

> † KMXD †
Report Abuse
Shadowknight619 is not online. Shadowknight619
Joined: 28 Sep 2010
Total Posts: 2453
27 Jun 2012 01:37 PM
Oh, thank you. You lot have been really helpful.
Report Abuse
Shadowknight619 is not online. Shadowknight619
Joined: 28 Sep 2010
Total Posts: 2453
27 Jun 2012 01:43 PM
.
Report Abuse
Shadowknight619 is not online. Shadowknight619
Joined: 28 Sep 2010
Total Posts: 2453
27 Jun 2012 01:44 PM
I have another problem from the Output but every time I try to post it, it takes me to the error page...
Report Abuse
Shadowknight619 is not online. Shadowknight619
Joined: 28 Sep 2010
Total Posts: 2453
27 Jun 2012 01:44 PM
I added lots of spaces so it lets me write it

Workspace. Model. Model. Bonnet. Script: 10: 'end' expected (to close 'function' at line 1) near ' < eof >'
Report Abuse
lombardo2 is not online. lombardo2
Joined: 30 Nov 2008
Total Posts: 1604
27 Jun 2012 01:53 PM
== Equals to, returns true or false
= Assigns a value to a variable
Report Abuse
lombardo2 is not online. lombardo2
Joined: 30 Nov 2008
Total Posts: 1604
27 Jun 2012 01:53 PM
equal*
Report Abuse
sparker22 is not online. sparker22
Joined: 11 Mar 2010
Total Posts: 846
27 Jun 2012 02:33 PM
@ShadowKnight619 You simply need another end.
Report Abuse
BladzofChaos70 is not online. BladzofChaos70
Joined: 27 Sep 2008
Total Posts: 2550
27 Jun 2012 03:12 PM
==, or equal to
<=, or less than or equal to
>=, or greater than or equal to,
<, or less then
>, or greater than
~=, or not equal to

Are all logic comparisons, or conditional statements. Used like this:

if [conditional] then -- checks to see if the conditional is true
if not [conditional] then -- checks to see if the conditional is false
if [conditional] or [conditional] then -- checks each statement to see if it is true
if [conditional] and [conditional] then -- checks to see if both statement is true

*Side note, the elseif statement can be used to contain multiple if statements within the same thread*

(those last two can contain any number of "ands" or "ors")

Conditionals are used the way they are named, they rely on a certain "condition" (defined in the script) to determine what to do next. If the condition is met (or alternatively, not met) then it will continue on through whatever is contained within the conditional. For instance:

if (x==y) then
print("X is equal to Y!")
end

It will only print "X is equal to Y!" if the condition is met. For instance, if both x and y were equal to 20. If x was 10, and y was 20, the condition would not be met, and therefore it wouldn't print "X is equal to Y!"


On the other hand, just 1 equal sign (=) is used to define something, generally speaking a variable.

boolean = true
number = 1000
string = "Clockwerk Angels"

Hope this helped and didn't go too far over your head. Good luck!
Report Abuse
Shadowknight619 is not online. Shadowknight619
Joined: 28 Sep 2010
Total Posts: 2453
27 Jun 2012 03:14 PM
Thank you, that is very helpful.

Can you help me with this please?
http://www.roblox.com/Forum/ShowPost.aspx?PostID=70911509
Report Abuse
awas3 is not online. awas3
Joined: 24 Oct 2010
Total Posts: 2854
27 Jun 2012 03:23 PM
If something is equal to something then
something = something
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image