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 » Scripters
Home Search
 

Accessing methods as a property

Previous Thread :: Next Thread 
ThatChristianGuy is not online. ThatChristianGuy
Joined: 14 Jun 2014
Total Posts: 1283
18 Nov 2014 09:02 AM
Could I access a method as a property, like this:

if part.IsA then


--ThatChristianGuy
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
18 Nov 2014 10:49 AM
Totally.

:IsA() is actually "syntactic sugar".

If you wanted to do it the longer way, or more correct way (I guess?), just use

if game.IsA(game.Workspace.Part, "BasePart") then
print("game.Workspace.Part is a BasePart!")
end
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
18 Nov 2014 10:52 AM
To be more specific, when you use the colon, it automatically gives the first argument as what precedes the colon.

When you use a dot, you need to supply the "self" argument, which is the first one.

so game.IsA is the "IsA" function.

local IsA = game.IsA

and to do Part:IsA("Part"), do

IsA(Part, "BasePart")


http://blog.roblox.com/2012/02/an-optimization-for-lua-scripts-2/
Report Abuse
ThatChristianGuy is not online. ThatChristianGuy
Joined: 14 Jun 2014
Total Posts: 1283
18 Nov 2014 11:35 AM
Yeah, Ik about the methods & such, I was just wondering if they were nonaccessible that way or something. Thanks!


--ThatChristianGuy
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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