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: Substituting string for

Previous Thread :: Next Thread 
johnhugh is not online. johnhugh
Joined: 26 Mar 2009
Total Posts: 1971
10 May 2013 09:01 PM
    Aname = script.Parent.Name
    p:findFirstChild("crystals").Aname.Value = true

Why doesn't Aname's string(it's **name**) work in making my boolvalue that has the same **name** true?


Let's say Aname = "pie" -- dont tell me to make Aname = "set stuffs" please. I have a reason
pie is a boolvalue
When it uses the line:
    p:findFirstChild("crystals").Aname.Value = true
It tells me Aname is not a valid member of it's parent


Help please
Report Abuse
ScrewDeath is not online. ScrewDeath
Joined: 03 Jun 2012
Total Posts: 2700
10 May 2013 09:02 PM
p:findFirstChild("crystals")[Aname].Value = true--Use [ ] when calling a variable in a path.
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
10 May 2013 09:04 PM
Use the bracket notation of indexing.


OBJECT["Property"] == OBJECT.Property


That said, you can also put variables in the brackets to evaluate them.


Var = "Property"
OBJECT[Var] == OBJECT.Property


Notice there is no . before the [ bracket.
Report Abuse
dekkonot is not online. dekkonot
Joined: 22 Dec 2010
Total Posts: 6685
10 May 2013 09:04 PM
Like this:

Aname = script.Parent.Name
p:findFirstChild("crystals")[Aname].Value = true

or

Aname = script.Parent.Name
p:findFirstChild("crystals"):findFirstChild(Aname).Value = true

~ Non simpliciter Latinam legere ~
Report Abuse
johnhugh is not online. johnhugh
Joined: 26 Mar 2009
Total Posts: 1971
10 May 2013 09:18 PM
Thanks I'll check it out in a bit
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