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: asdf

Previous Thread :: Next Thread 
thedeathmaster01 is not online. thedeathmaster01
Joined: 14 Mar 2010
Total Posts: 6331
22 Jul 2012 11:56 PM
So, I have a stringvalue with a simple line of code (print) and how do I load it into a script? So I can change the code with another script.

here is what I have and it doesn't work

code = Workspace.Value.Value

.. code .. -- That is supposed to load the code inside of the string value

help!?!?
Report Abuse
ninjaknight101 is not online. ninjaknight101
Joined: 04 Apr 2011
Total Posts: 1281
22 Jul 2012 11:57 PM
You can only use loadstring() once :(
Report Abuse
thedeathmaster01 is not online. thedeathmaster01
Joined: 14 Mar 2010
Total Posts: 6331
22 Jul 2012 11:59 PM
So do I do

code = Workspace.Value.Value

loadstring(code)

??
Report Abuse
ninjaknight101 is not online. ninjaknight101
Joined: 04 Apr 2011
Total Posts: 1281
23 Jul 2012 12:02 AM
Yes
Report Abuse
thedeathmaster01 is not online. thedeathmaster01
Joined: 14 Mar 2010
Total Posts: 6331
23 Jul 2012 12:02 AM
Ok, but if I want it to run every time I change it; can I disable and re-enable it again?
Report Abuse
ninjaknight101 is not online. ninjaknight101
Joined: 04 Apr 2011
Total Posts: 1281
23 Jul 2012 12:10 AM
I guess you could... Not a bad idea xD
Report Abuse
thedeathmaster01 is not online. thedeathmaster01
Joined: 14 Mar 2010
Total Posts: 6331
23 Jul 2012 12:22 AM
Ok, I get no output. I just did


code = script.Parent.Value.Value

loadstring(code)


this is a script inside of a part with a loadstring inside of the part also with a print("Hi").

And it doesn't work.

:\
Report Abuse
thedeathmaster01 is not online. thedeathmaster01
Joined: 14 Mar 2010
Total Posts: 6331
23 Jul 2012 12:26 AM
??
Report Abuse
ninjaknight101 is not online. ninjaknight101
Joined: 04 Apr 2011
Total Posts: 1281
23 Jul 2012 12:28 AM
Sorry, you have to add the () after it. Derp


loadstring([==[print("YO")]==])()
Report Abuse
StygianBlade is not online. StygianBlade
Joined: 15 Sep 2011
Total Posts: 426
23 Jul 2012 12:29 AM
Loadstring returns a function, which contains the actual code. You would have to do


source = [[code]]

loadstring(code)()


or if you want to call the code multiple times

source = loadstring([[
code
]]

source() --source is now a function
Report Abuse
thedeathmaster01 is not online. thedeathmaster01
Joined: 14 Mar 2010
Total Posts: 6331
23 Jul 2012 12:34 AM
Ok, that makes sense.
Report Abuse
CloneTrooper1019 is not online. CloneTrooper1019
Joined: 19 Jan 2009
Total Posts: 6227
23 Jul 2012 12:36 AM
loadstring(code)()
Report Abuse
CloneTrooper1019 is not online. CloneTrooper1019
Joined: 19 Jan 2009
Total Posts: 6227
23 Jul 2012 12:37 AM
It looks weird I know. But that is how it works.
Report Abuse
DragonWarlord101 is not online. DragonWarlord101
Joined: 26 Oct 2008
Total Posts: 363
23 Jul 2012 12:42 AM
code = loadstring(workspace.StringVal.Value)()

code("Hello World!")

If the only line of code in the value is 'print', the above should work.
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