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: How do we know what the scripting basics are?

Previous Thread :: Next Thread 
Kepie is not online. Kepie
Joined: 12 Nov 2011
Total Posts: 884
04 Jul 2012 05:51 AM
???
Report Abuse
Cheater is not online. Cheater
Joined: 29 Jun 2007
Total Posts: 5258
04 Jul 2012 05:52 AM
http://wiki.roblox.com/index.php/Basic_Scripting
Report Abuse
Kepie is not online. Kepie
Joined: 12 Nov 2011
Total Posts: 884
04 Jul 2012 05:58 AM
@Cheater, i just checked it out, and ik all that stuff, but two things, the GetChildren thing, i wouldnt learn that yet looks complicated, anyway, why does some script set Parent.Parent sometimes and they even have 3 parents what do they do, ik parent, we set it to something and that,but what are they used to, and why?
Report Abuse
zars15 is not online. zars15
Joined: 10 Nov 2008
Total Posts: 9999
04 Jul 2012 05:59 AM
Here = "Now".."ur"
Done = Here
Report Abuse
ggfunny1234 is not online. ggfunny1234
Joined: 09 Jul 2010
Total Posts: 3432
04 Jul 2012 06:00 AM
:GetChildren() isn't that complicated. Here's an example.

print(game.Players:GetChildren())

For some scripts, if a script is deep inside a model or another object, and you want to create a new instance (this is an example) and put it in a higher part of the model, you go through the hierarchy with Parent.
Report Abuse
Kepie is not online. Kepie
Joined: 12 Nov 2011
Total Posts: 884
04 Jul 2012 06:16 AM
@gg ik getchildren, but other things in script like loops and that BUT I DONT CARE ABOUT THAT RIGHT NOW, why do we need Parent.Parent or Parent.Parent.Parent or more in scripts and what are they used to.Any examples?
Report Abuse
Cheater is not online. Cheater
Joined: 29 Jun 2007
Total Posts: 5258
04 Jul 2012 06:18 AM
Parent is used to get one upwards in the tree.

Like, let's say you have a Part inside a Model in Workspace. Then the tree looks like this:

game
-Worksapce
--Model
---Part
----Sript
-Lighting
-StarterGui

So how you can see, the script would be inside that part and now, if we want to have acces to the Lighting or something we just do this:

g = script.Parent.Parent.Parent.Parent --g will be a shortcut for the top (game) of the tree
g.Lighting

You could also just write:

game.Lighting

But sometimes it's necessary to use Parent.

And the :GetChildren() is a very important function to take several objects at once.
Report Abuse
ggfunny1234 is not online. ggfunny1234
Joined: 09 Jul 2010
Total Posts: 3432
04 Jul 2012 06:19 AM
Alright. Here's an example of using parent.

-Model1
--Part
---Script

This shows the model under the workspace, the Part inside it, and the Script inside the Part.

Let's say the Script contains code which creates a new Part when a certain function is fired. To place that Part directly under the model, you would do:

newPart.Parent = script.Parent.Parent -- There are more effective ways of doing this, but that's just to show you. script.Parent is sort of built in, because no matter what the name of the script you're editing is called, saying 'script.Parent' automatically lists the parent of said script.
Report Abuse
ggfunny1234 is not online. ggfunny1234
Joined: 09 Jul 2010
Total Posts: 3432
04 Jul 2012 06:20 AM
CHEATER, GET OUT. THIS IS MY NOOB.

:O
Report Abuse
Cheater is not online. Cheater
Joined: 29 Jun 2007
Total Posts: 5258
04 Jul 2012 06:21 AM
I've started replying, so I'll finish with him.
Report Abuse
Kepie is not online. Kepie
Joined: 12 Nov 2011
Total Posts: 884
04 Jul 2012 06:21 AM
Can u explain another way BUT WITH THE TREE??
Report Abuse
ggfunny1234 is not online. ggfunny1234
Joined: 09 Jul 2010
Total Posts: 3432
04 Jul 2012 06:21 AM
qq.
Report Abuse
Kepie is not online. Kepie
Joined: 12 Nov 2011
Total Posts: 884
04 Jul 2012 06:25 AM
...
Report Abuse
Cheater is not online. Cheater
Joined: 29 Jun 2007
Total Posts: 5258
04 Jul 2012 06:27 AM
game
-Workspace
--Randomplayer
---Humanoid
---Torso
--Part
---Ourscript

Let's say the Torso of that random person just touched the brick and the script start's running now.

function touch(hit)
player = game.Players:GetPlayerFromCharacter(hit.Parent) --Alright. This will take the player from the whole playerlist, who touched that Part. hit.Parent in this case is the "Randomplayer" inside Workspace. Why? Because the Torso touched that Part and the Parent of Torso is Randomplayer
h = hit.Parent.Humanoid --get what I mean?
h.Health = 0 --will kill the Randomplayer
script.Parent.Touched:connect(touch) --script.Parent = Part because the script is inside Part
Report Abuse
Kepie is not online. Kepie
Joined: 12 Nov 2011
Total Posts: 884
04 Jul 2012 06:33 AM
So, h = hit.Parent.Humanoid the Parent there is the RandomPlayer?
Report Abuse
Cheater is not online. Cheater
Joined: 29 Jun 2007
Total Posts: 5258
04 Jul 2012 06:35 AM
Yes.
Report Abuse
Kepie is not online. Kepie
Joined: 12 Nov 2011
Total Posts: 884
04 Jul 2012 06:37 AM
And humanoid is called the child of it?
Report Abuse
Cheater is not online. Cheater
Joined: 29 Jun 2007
Total Posts: 5258
04 Jul 2012 06:38 AM
Humanoid is an object inside Randomplayer.
Report Abuse
Kepie is not online. Kepie
Joined: 12 Nov 2011
Total Posts: 884
04 Jul 2012 06:42 AM
Ik that, and thats why its a child right? cuzz its something inside randomplayer?
Report Abuse
Cheater is not online. Cheater
Joined: 29 Jun 2007
Total Posts: 5258
04 Jul 2012 06:43 AM
Yes. Via a = Randomplayer:GetChildren() you'll have it in your table a.
Report Abuse
Kepie is not online. Kepie
Joined: 12 Nov 2011
Total Posts: 884
04 Jul 2012 06:44 AM
Ok i get how parent works now, thx cheater.
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