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
We use cookies to offer you a better experience. By using Roblox.com, you are agreeing to our Privacy and Cookie Policy.
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Is there a faster way to find parents than listing them all?

Previous Thread :: Next Thread 
Zecrit is not online. Zecrit
Joined: 24 Jan 2013
Total Posts: 2618
04 Jun 2014 06:34 AM
Because I'm just working on a GUI and the parent I need to get to has to be listed like:
script.Parent.Parent.Parent.Parent.Parent.(Thing)
Can this be shortened just for perfectionism and aesthetic purposes?
Report Abuse
Ultraw is not online. Ultraw
Joined: 20 Nov 2010
Total Posts: 6575
04 Jun 2014 06:41 AM
No, what you need to do is define what you need at the start of the script as a variable. For example: frame = script.Parent.Parent.Parent. From there, just use "frame" when use it.
Report Abuse
velociraptori is not online. velociraptori
Joined: 03 Jan 2009
Total Posts: 302
04 Jun 2014 06:41 AM
Nope.




...As far as i'm concerned...
Report Abuse
Zecrit is not online. Zecrit
Joined: 24 Jan 2013
Total Posts: 2618
04 Jun 2014 06:45 AM
Oh yea, thanks.
Report Abuse
COOLDUDE11OO is not online. COOLDUDE11OO
Joined: 21 Aug 2011
Total Posts: 5115
04 Jun 2014 07:22 AM
plr = script.Parent
repeat plr = plr.Parent until plr:IsA('Player')
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
04 Jun 2014 08:52 AM
It's best to start off from the player down.


wait(1)
local Player = game.Players.LocalPlayer
local MyGui = Player.PlayerGui.MyGui

local Frame1 = MyGui.Frame1
local F1Btn = Frame1.ClickyButton
local F1Label = Frame1.FunnyJokeLabel

local TestFrame = MyGui.Frame2
local TFBtn = TestFrame.AnotherClickyButton
local TFLabel = TestFrame.HorribleJokeLabel
local TFLabelFunny = TFLabel.Funny.Value
--> this happens to be false!


I hope I didn't go too far. :o


I also recommend having ONE script directly under the ScreenGui object. That way you KNOW for a FACT where the ScreenGui is and all of its children. Don't forget to use a LocalScript, as normal Scripts do not run in the PlayerGui.
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