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: What's more efficient Example.object or Example[object]?

Previous Thread :: Next Thread 
CLIMAXIMUS is not online. CLIMAXIMUS
Joined: 22 Jun 2012
Total Posts: 1738
05 Aug 2014 09:38 PM
Just curious, because I like Example[object]
Report Abuse
Badfitz100 is not online. Badfitz100
Joined: 03 Nov 2010
Total Posts: 12591
05 Aug 2014 09:42 PM
[ Content Deleted ]
Report Abuse
NetsFan0 is not online. NetsFan0
Joined: 17 Apr 2009
Total Posts: 2777
05 Aug 2014 09:42 PM
I believe the second can only be used if say, you were looking for something named the same thing as a variable's name. For example if you have a variable named hello and you were looking for example's child named what hello was named uou would say Example[hello.Name] otherwise you use Example.object to find it.

ɪᴛ ᴀɪɴ'ᴛ ᴇᴀsʏ, ʙᴇɪɴɢ ᴀ ɴᴀᴅᴀʟ ʜᴀᴛᴇʀ
Report Abuse
blockoo is not online. blockoo
Joined: 08 Nov 2007
Total Posts: 17202
05 Aug 2014 09:43 PM
They are the same, but I honestly don't know why you would bother doing this:

game["Workspace"]["Player1"]["Head"]["CFrame"] = CFrame.new()

When you could just:
game.Workspace.Player1.Head.CFrame = CFrame.new()

Way shorter and less tedious to type.
Report Abuse
NetsFan0 is not online. NetsFan0
Joined: 17 Apr 2009
Total Posts: 2777
05 Aug 2014 09:43 PM
Or at least that's how I use them, I'm not sure if you CAN'T use them differently.

ɪᴛ ᴀɪɴ'ᴛ ᴇᴀsʏ, ʙᴇɪɴɢ ᴀ ɴᴀᴅᴀʟ ʜᴀᴛᴇʀ
Report Abuse
CLIMAXIMUS is not online. CLIMAXIMUS
Joined: 22 Jun 2012
Total Posts: 1738
06 Aug 2014 11:44 AM
herm
Report Abuse
CLIMAXIMUS is not online. CLIMAXIMUS
Joined: 22 Jun 2012
Total Posts: 1738
06 Aug 2014 11:45 AM
Well I use both ig just sometimes it's more fun to Example[object] because it looks better. :P
Report Abuse
devSurface is not online. devSurface
Joined: 09 Feb 2013
Total Posts: 1339
06 Aug 2014 11:49 AM
Things like this;

game.Workspace.Part Test:destroy()
dont work cuz the spacew ill break the script;

So the [""] is used for names with an space.

like;
game.Workspace["Part Test"]:destroy()
Report Abuse
blockoo is not online. blockoo
Joined: 08 Nov 2007
Total Posts: 17202
06 Aug 2014 12:05 PM
^
That's really the only reason it should be used.
Report Abuse
Badfitz100 is not online. Badfitz100
Joined: 03 Nov 2010
Total Posts: 12591
06 Aug 2014 01:18 PM
[ Content Deleted ]
Report Abuse
blockoo is not online. blockoo
Joined: 08 Nov 2007
Total Posts: 17202
06 Aug 2014 01:27 PM
Not any neater than:

player.Character
char.Humanoid

Personally I think that looks better.
Report Abuse
CLIMAXIMUS is not online. CLIMAXIMUS
Joined: 22 Jun 2012
Total Posts: 1738
07 Aug 2014 08:01 AM
sp["Name"] looks better than sp.Name
Report Abuse
DeadzoneRemadeBot is not online. DeadzoneRemadeBot
Joined: 24 Jul 2014
Total Posts: 116
07 Aug 2014 08:18 AM
I don't honestly care how neat a script is
Report Abuse
blockoo is not online. blockoo
Joined: 08 Nov 2007
Total Posts: 17202
07 Aug 2014 08:56 AM
Well, it's a matter of opinion. It might look better to you, but it actually looks worse to me. Even so, you you really think it's worth the extra time to type it?
Report Abuse
filiptibell is online. filiptibell
Joined: 10 Mar 2013
Total Posts: 2362
07 Aug 2014 09:01 AM
Y'all need to google "syntactic sugar"

~The herp lerped a derp~
Report Abuse
CLIMAXIMUS is not online. CLIMAXIMUS
Joined: 22 Jun 2012
Total Posts: 1738
07 Aug 2014 03:23 PM
Yes. It doesn't matter how much I type, honestly. Whatever is the most defined and organized, I'm kinda OCD with my scripting.
Report Abuse
sbk28 is not online. sbk28
Joined: 15 Nov 2008
Total Posts: 2528
07 Aug 2014 03:25 PM
Example[object] is technically more efficient due to the fact that it won't get confused with properties or variables that might be related to the object
Report Abuse
CLIMAXIMUS is not online. CLIMAXIMUS
Joined: 22 Jun 2012
Total Posts: 1738
07 Aug 2014 03:26 PM
>:D
Report Abuse
blockoo is not online. blockoo
Joined: 08 Nov 2007
Total Posts: 17202
07 Aug 2014 03:27 PM
@sbk
Bracket notation will find properties as well:

game.Workspace.Part["Size"] = Vector3.new()
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
07 Aug 2014 03:29 PM
Good luck being consistent when using brackets.

local part = Game["Workspace"]["Model"]["Part"];
local touched = part["Touched"];
touched["connect"](touched, function(hit)
local hitter = hit["GetFullName"];
print(hitter(hit));
end);
Report Abuse
CLIMAXIMUS is not online. CLIMAXIMUS
Joined: 22 Jun 2012
Total Posts: 1738
07 Aug 2014 03:29 PM
-.-
Report Abuse
sbk28 is not online. sbk28
Joined: 15 Nov 2008
Total Posts: 2528
07 Aug 2014 03:31 PM
@blockoo

my bad I must have been confusing them for something else
Report Abuse
CLIMAXIMUS is not online. CLIMAXIMUS
Joined: 22 Jun 2012
Total Posts: 1738
07 Aug 2014 03:40 PM
I'm not talking about ONLY using them, I just mean more than I need to... not [s][d]... that just looks weird
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