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: can someone please break this down for me

Previous Thread :: Next Thread 
GhostKilla45 is not online. GhostKilla45
Joined: 25 Dec 2013
Total Posts: 2241
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 is not online. yankeejr
Joined: 04 Jul 2012
Total Posts: 4906
12 Jan 2014 10:08 PM
wait(1) messes it up
Report Abuse
cntkillme is not online. 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
GhostKilla45 is not online. GhostKilla45
Joined: 25 Dec 2013
Total Posts: 2241
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
nighttimeninja314 is not online. nighttimeninja314
Joined: 04 Apr 2011
Total Posts: 4001
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
GhostKilla45 is not online. GhostKilla45
Joined: 25 Dec 2013
Total Posts: 2241
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 is not online. 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
GhostKilla45 is not online. GhostKilla45
Joined: 25 Dec 2013
Total Posts: 2241
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
nighttimeninja314 is not online. nighttimeninja314
Joined: 04 Apr 2011
Total Posts: 4001
12 Jan 2014 10:14 PM
Yep.
Report Abuse
cntkillme is not online. 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
GhostKilla45 is not online. GhostKilla45
Joined: 25 Dec 2013
Total Posts: 2241
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
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