|
| 12 Oct 2013 07:47 PM |
1. Child in pairs
2. functions (especially the part after like 'function(whatgoeshere)'
3. ..playername and how do i give a message to a particular person
4. parenthesis (where to put them) |
|
|
| Report Abuse |
|
|
| |
|
|
| 12 Oct 2013 07:51 PM |
for the parenthesis part i need help on like
onplayerjoined))()(()()()()()( -- <-- craziness here
and i need to understand this onplayerjoined.
another parenthesis example would be like
end) end) |
|
|
| Report Abuse |
|
|
| |
|
|
| 12 Oct 2013 07:54 PM |
umg.
u guys all hate me or somethin
): |
|
|
| Report Abuse |
|
|
Geomaster
|
  |
| Joined: 05 Jul 2008 |
| Total Posts: 1480 |
|
|
| 12 Oct 2013 07:56 PM |
Functions all have parantheses, and you can put arguments in them (but you don't have to.)
Functions basically work like this:
function functioname(arguments) end -- The word 'function' to show we're making a function, the name of the function, and any arguments inside them, and 'end' to close the function.
Example of a function with no arguments:
local a = 2
function printA() print(a) -- Gonna put whatever a is in the output end
printA() -- calling the function, always use parantheses when calling it
-- Output shows 2
Example of one WITH arguments:
local a = 2
function printNum(num) print(num) -- prints whatever num is, which we decide later end
printNum(a) -- Calling the function using 'a' in place of 'num'
|
|
|
| Report Abuse |
|
|
Geomaster
|
  |
| Joined: 05 Jul 2008 |
| Total Posts: 1480 |
|
|
| 12 Oct 2013 07:59 PM |
Also, most functions won't have parantheses at the end unless:
- You connect the function in the same line you make it (also called anonymous functions) - You put it inside a coroutine - You just feel like putting them there
For example, instead of:
function printName(hit) -- Function here print(hit.Name) end
game.Workspace.Brick.Touched:connect(printName) -- Connection here
We do this:
game.Workspace.Brick.Touched:connect(function(hit) -- Connection AND Function print(hit.Name) end)
|
|
|
| Report Abuse |
|
|
|
| 12 Oct 2013 08:01 PM |
1. Child in pairs
That is used to do a specific function to every member in a table
The table goes in for i,v in pairs(table) do --v is the child end
2. functions (especially the part after like 'function(whatgoeshere)'
Functions are used for various reasons. They are mostly used for Events, Organization, and Cleanliness. You write a function like: function hi()
The paranthesis are the parameters for the function. It is useful for if you want to perform the same function on different things with having to make a whole function. Example: funtion Hi(text)--Creating the function print(text) end Hi("assasds")--Calling the function with the text inside. You can also connect a function to an event. An event is basically when something happens to something else. In the object browser there is a bunch of events
3. ..playername and how do i give a message to a particular person
Idk what you mean by playername but to give a message to a particular function you put the Message in PlayerGui
4. parenthesis (where to put them)
Parenthesis should only be put for methods, connect lines, math strings and stuff like that, and functions. Atleast thats all I know... Anyway when people put end) on stuff they are usually connect a function that hasn't been created to an event, so they are making the function inside the connecting line. So say part.Touched:connect( function()--Creating a function without a name
Your crap end--ending the function and closing the connection line. |
|
|
| Report Abuse |
|
|
MHebes
|
  |
| Joined: 04 Jan 2013 |
| Total Posts: 2278 |
|
|
| 12 Oct 2013 08:05 PM |
| I'm writing a bit of a wall of text atm, I'll post it soonish. |
|
|
| Report Abuse |
|
|
MHebes
|
  |
| Joined: 04 Jan 2013 |
| Total Posts: 2278 |
|
| |
|