|
| 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 |
|
|
|
| 22 Jul 2012 11:57 PM |
| You can only use loadstring() once :( |
|
|
| Report Abuse |
|
|
|
| 22 Jul 2012 11:59 PM |
So do I do
code = Workspace.Value.Value
loadstring(code)
?? |
|
|
| Report Abuse |
|
|
| |
|
|
| 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 |
|
|
|
| 23 Jul 2012 12:10 AM |
| I guess you could... Not a bad idea xD |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
| |
|
|
| 23 Jul 2012 12:28 AM |
Sorry, you have to add the () after it. Derp
loadstring([==[print("YO")]==])() |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
| |
|
| |
|
|
| 23 Jul 2012 12:37 AM |
| It looks weird I know. But that is how it works. |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|