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 String Values be used for Object Paths in Scripts?

Previous Thread :: Next Thread 
BogyMac is not online. BogyMac
Joined: 04 Nov 2011
Total Posts: 823
18 Sep 2013 06:15 PM
I am having to rename a spawned model to have a certain name and then add the Player's name after it. I have gotten this to work correctly, but in order to avoid confusion in scripts, I need it to be able to use a String Value as an Object Path, but this doesn't seem to be possible as far as I know.


Is it possible to make something like this work?


What I have so far:

Script 1:

script.Parent.Parent.vehiclePath.Value = ("game.Workspace."..script.Parent.Parent.vehicleName..game.Players.LocalPlayer.Name)
-----------------------------------------------------------------------------------------------------------------------------
Script 2

workspace.CurrentCamera.CameraSubject = script.Parent.vehiclePath.Value

Thanks for any help,
-Bogy
Report Abuse
BogyMac is not online. BogyMac
Joined: 04 Nov 2011
Total Posts: 823
18 Sep 2013 06:34 PM
Help Please? I would really appreciate it! :)
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
18 Sep 2013 06:35 PM
Obviously not.
You can't change your camerasubject to a string.
Report Abuse
BogyMac is not online. BogyMac
Joined: 04 Nov 2011
Total Posts: 823
18 Sep 2013 06:38 PM
Yes, I know. But I was wondering if there was a way of doing anything similar (like have the Object Path link to any sort of a Global Variable (Object Values, maybe? Not sure how to use them yet))
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
18 Sep 2013 06:39 PM
ObjectPath[String]

Like

StringValue = "Part"
game.Workspace[StringValue]:Destroy()
Report Abuse
BogyMac is not online. BogyMac
Joined: 04 Nov 2011
Total Posts: 823
18 Sep 2013 06:42 PM
Okay. Also, one question. I know what Parentheses are used for, I use them all the time. But, what exactly are Brackets ( [ ] ) used for?
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
18 Sep 2013 06:43 PM
Brackets are used for indexing
Report Abuse
BogyMac is not online. BogyMac
Joined: 04 Nov 2011
Total Posts: 823
18 Sep 2013 06:44 PM
Okay, thanks, I appreciate the help! :D
Report Abuse
crazyman32 is online. crazyman32
Joined: 13 Apr 2008
Total Posts: 18027
18 Sep 2013 07:04 PM
Loadstring

workspace.CurrentCamera.CameraSubject = loadstring("return " .. script.Parent.vehiclePath.Value)()
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