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: I still dont understand some things, help

Previous Thread :: Next Thread 
skyarex is not online. skyarex
Joined: 21 Mar 2010
Total Posts: 12989
29 Nov 2013 12:40 PM
I still don't understand the symbols [] in scripting, or the symbol #


Also, I still don't understand arguments. I get how some scripts use them (for example, you have to make the arguments for print otherwise it wont print anything) but I don't understand how you make them. How does putting in words in the parenthesis in a function you have just made change anything?

"Don't Panic"- HHGTTG
Report Abuse
PRESTIGIOUSaLEGEND is not online. PRESTIGIOUSaLEGEND
Joined: 16 Apr 2011
Total Posts: 1765
29 Nov 2013 12:44 PM
[] index

game.workspace["Part"] is the same as
game.workspace.Part

# number

#workspace:GetChildren() returns the number of things in workspace

example2

MODEL
>PART
>PART2
>Value
>MODEL
>CHARACTER

#MODEL:GetChildren() will return 5, as there are 5 children
Report Abuse
Jetta765214 is not online. Jetta765214
Joined: 22 Oct 2008
Total Posts: 1855
29 Nov 2013 12:49 PM
The [] symbol can do 2 things.

If you use double of them ([[ or ]]) then it creates a longer string, which can be multiple lines.

Example:

[[hello
world]]

would be fine

"hello
world"

would error.

The second use it to access indexes in a table. It is the same as doing .something but can include spaces/dots/what ever stuff isn't allow.

Example:

game.Workspace["Part 1"]

tab = {}
tab["Space "] = 5

game.Workspace["Part.1"]

these would all work fine.

game.Workspace.Part 1--Would error

tab = {}
tab.Space = 5 --You would be unable to add the space after 'space'

game.Workspace.Part.1--1 is not a valid child of Part

these all would error

Now for the # symbol. It basically stands for number of. It is the same as string.len() or table.getn(). What it does is tell you the length of a string, or the number of indexes.

Examples:

str = "asdfasdfadsf"

print(#str)
print(string.len(str))
-->both would print 12, since the string contains 12 characters.

tab = {1,2,3,4,5,6,7,8,9}
print(#tab)
print(table.getn)
-->Both would print 9, since there are 9 indexes.

Hope this helps, just say if any of this confuses you
Report Abuse
Ekkoh is not online. Ekkoh
Joined: 22 Oct 2012
Total Posts: 524
29 Nov 2013 12:52 PM
Did you even understand his question?

@OP
Consider this example

function kill() -- in this function, we cannot decide who dies. Player1 would die no matter what.
Game.Players:FindFirstChild("Player1").Character:BreakJoints()
end

function kill(player_name) -- we could say kill("ekkoh") and it would kill me instead of a default to whatever the function is
Game.Players:FindFirstChild(player_name).Character:BreakJoints()
end


"We can walk a million miles, and end up in the sea." - George Ragan aka Johnny 3 Tears
Report Abuse
skyarex is not online. skyarex
Joined: 21 Mar 2010
Total Posts: 12989
29 Nov 2013 12:54 PM
>The second use it to access indexes in a table.

What is that?

"Don't Panic"- HHGTTG
Report Abuse
Duelingwarlord is not online. Duelingwarlord
Joined: 15 Feb 2010
Total Posts: 22333
29 Nov 2013 12:57 PM
you can also use [] for an array

array_name = [] --An array which stores multiple values

array_full = [2,"hi",nil] --An array filled with values

To call an array simply do this:

for _,v in pairs(array_full) do
print(v) --v is the array_full
--or other code here n stuff
end
Report Abuse
Ekkoh is not online. Ekkoh
Joined: 22 Oct 2012
Total Posts: 524
29 Nov 2013 01:02 PM
This isn't JavaScript, they're not called arrays, you can't instantiate them with brackets. This is Lua, they're called tables, and you use curly braces to instantiate them ({}).

"We can walk a million miles, and end up in the sea." - George Ragan aka Johnny 3 Tears
Report Abuse
Duelingwarlord is not online. Duelingwarlord
Joined: 15 Feb 2010
Total Posts: 22333
29 Nov 2013 01:03 PM
ok w/e echo

I think the point got across anyway.
Report Abuse
SamuelKingx is not online. SamuelKingx
Joined: 27 Jan 2012
Total Posts: 3472
29 Nov 2013 01:05 PM
@duel

No, it didn't. You were giving false information.
Report Abuse
KEVEKEV77 is not online. KEVEKEV77
Joined: 12 Mar 2009
Total Posts: 6961
29 Nov 2013 01:09 PM
You can also use them to get information form a table
A table is a configuration of different thing.

ex:

local myfirsttable = {1,2,3,4,6,2} -- use the {} to make a table
print (myfirttable[5]) -- this will print 6, because it is the 5th one
Report Abuse
Duelingwarlord is not online. Duelingwarlord
Joined: 15 Feb 2010
Total Posts: 22333
29 Nov 2013 01:11 PM
It still can be called an array, >just verified

however you are right with the brackets
Report Abuse
skyarex is not online. skyarex
Joined: 21 Mar 2010
Total Posts: 12989
29 Nov 2013 01:11 PM
@Ek

Ohhh. I already knew about arrays. I never knew you called them tables in Lua

"Don't Panic"- HHGTTG
Report Abuse
SamuelKingx is not online. SamuelKingx
Joined: 27 Jan 2012
Total Posts: 3472
29 Nov 2013 01:13 PM
How do all of these people new to Lua have Bloxy's?

How were the obtained?
Report Abuse
skyarex is not online. skyarex
Joined: 21 Mar 2010
Total Posts: 12989
29 Nov 2013 01:20 PM
>How were the obtained?

Illegally.

"Don't Panic"- HHGTTG
Report Abuse
skyarex is not online. skyarex
Joined: 21 Mar 2010
Total Posts: 12989
30 Nov 2013 01:07 AM
BUMP

"Don't Panic"- HHGTTG
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
30 Nov 2013 01:35 AM
Damn jetta
Report Abuse
Ekkoh is not online. Ekkoh
Joined: 22 Oct 2012
Total Posts: 524
30 Nov 2013 10:15 PM
OP got banned...

"We can walk a million miles, and end up in the sea." - George Ragan aka Johnny 3 Tears
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