| |
|
|
| 27 Jun 2012 01:27 PM |
Basically:
= Used for setting
== Used for comparing
> † KMXD † |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 27 Jun 2012 01:34 PM |
^Also, that one needs an end .
> † KMXD † |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 27 Jun 2012 01:37 PM |
| Oh, thank you. You lot have been really helpful. |
|
|
| Report Abuse |
|
|
| |
|
|
| 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 |
|
|
|
| 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
|
  |
| 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
|
  |
| Joined: 30 Nov 2008 |
| Total Posts: 1604 |
|
| |
|
sparker22
|
  |
| Joined: 11 Mar 2010 |
| Total Posts: 846 |
|
|
| 27 Jun 2012 02:33 PM |
| @ShadowKnight619 You simply need another end. |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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
|
  |
| Joined: 24 Oct 2010 |
| Total Posts: 2854 |
|
|
| 27 Jun 2012 03:23 PM |
If something is equal to something then something = something |
|
|
| Report Abuse |
|
|