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: How come some functions require ":" and others need "."

Previous Thread :: Next Thread 
Collector4D is not online. Collector4D
Joined: 28 Jun 2014
Total Posts: 7296
09 Jul 2014 11:46 AM
Like one function might be
:Remove()
and another
.Remove()

Is it because the function is after/before the argument?
Report Abuse
Collector4D is not online. Collector4D
Joined: 28 Jun 2014
Total Posts: 7296
09 Jul 2014 11:51 AM
bump
Report Abuse
WishNite is not online. WishNite
Joined: 11 Feb 2009
Total Posts: 15828
09 Jul 2014 11:52 AM
I have never seen people use .Thing() before
Report Abuse
Collector4D is not online. Collector4D
Joined: 28 Jun 2014
Total Posts: 7296
09 Jul 2014 11:54 AM
Oh right, so : is always followed by the function name?
Report Abuse
oxcool1 is not online. oxcool1
Joined: 05 Nov 2009
Total Posts: 15444
09 Jul 2014 11:55 AM
':' gives a first argument of 'self'

Quick example:

game.Destroy(workspace.Base)

is same as

workspace.Base:Destroy()
Report Abuse
FreeScriptMaker is not online. FreeScriptMaker
Joined: 29 Nov 2013
Total Posts: 2275
09 Jul 2014 11:56 AM
"':' gives a first argument of 'self'"

That is not true at all.
Report Abuse
RoflBread is not online. RoflBread
Joined: 18 Jun 2009
Total Posts: 3803
09 Jul 2014 11:58 AM
Yes it is.

table.function(self, arg) == table:function(arg)
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
09 Jul 2014 11:59 AM
local t = {
f = function(a)
print(a)
end
}

t.f()
t:f()



So yes, it is 100% true.
Report Abuse
Collector4D is not online. Collector4D
Joined: 28 Jun 2014
Total Posts: 7296
09 Jul 2014 11:59 AM
Oh I see, thanks for the help.

I'd rather use the : as it is easier to understand
Report Abuse
FreeScriptMaker is not online. FreeScriptMaker
Joined: 29 Nov 2013
Total Posts: 2275
09 Jul 2014 12:00 PM
You are correct sorry.
Report Abuse
oxcool1 is not online. oxcool1
Joined: 05 Nov 2009
Total Posts: 15444
09 Jul 2014 12:00 PM
Another example to better explain it:

local t = {
method = function(self)
print(self == t)
end
}


t:method()
> true -- self is the table t

t.method()
> false -- self is nil
Report Abuse
FreeScriptMaker is not online. FreeScriptMaker
Joined: 29 Nov 2013
Total Posts: 2275
09 Jul 2014 12:01 PM
I already tested it myself you can stop posting examples now.
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
09 Jul 2014 12:02 PM
@ox
You'll have to make 't' an upvalue in that case, because t.method cannot actually access t itself unless you use the self parameter.

Just a small nit-picky thing. :P
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