|
| 12 Jan 2014 10:07 PM |
p = game.Players:GetChildren() for i = 1, #p do p[i].Character.Torso.CFrame = CFrame.new(Vector3.new(0, 0, 0)) wait(1) -- waits 1 second end
I know this is a simple teleport script, but what does #p mean ? also what do brackets do and how are they used ? (p[i])
~RobloxProfit; add 40k posts to my post count |
|
|
| Report Abuse |
|
|
yankeejr
|
  |
| Joined: 04 Jul 2012 |
| Total Posts: 4906 |
|
| |
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 12 Jan 2014 10:08 PM |
#p means length of p, which is a table, since the GetChildren method returns a table of all descendants of an object (in this case, game.Players) The brackets are used for indexing, since p is a table, p[1] gets the first value of the table |
|
|
| Report Abuse |
|
|
|
| 12 Jan 2014 10:09 PM |
i really just need to understand #p and p[i]
because I'm just trying to find scripts with examples used
~RobloxProfit; add 40k posts to my post count |
|
|
| Report Abuse |
|
|
|
| 12 Jan 2014 10:10 PM |
#p is the number of players. When you use for I =, each player is assigned a number. P[I] gets the player assigned to the current number as it loops through the script. |
|
|
| Report Abuse |
|
|
|
| 12 Jan 2014 10:10 PM |
@cnt
I under stand the second part
p[1] just chooses what part of the table basically
but #p was a little confusing, maybe a little simpler?
~RobloxProfit; add 40k posts to my post count |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 12 Jan 2014 10:11 PM |
#p just gets the length of a table (or string) So if I have a table: x = {"a", "b", "c"} Then #x would be 3, since there are 3 values in the table |
|
|
| Report Abuse |
|
|
|
| 12 Jan 2014 10:14 PM |
so,
#p means the number of children that the variable p finds?
~RobloxProfit; add 40k posts to my post count |
|
|
| Report Abuse |
|
|
| |
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 12 Jan 2014 10:14 PM |
No, it means the number of values the table (or string) has. Well, you could say it like that but it's not really correct |
|
|
| Report Abuse |
|
|
|
| 12 Jan 2014 10:17 PM |
I made a simple script using # and it worked
script.Parent.Touched:connect(function() p = game.Players:GetChildren() print(#p) end)
I made this function inside a brick and called it when it's touched
it worked!
thank you everyone
~RobloxProfit; add 40k posts to my post count |
|
|
| Report Abuse |
|
|