Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I make LoadString turn a String into a Script?

Asked by 7 years ago

So I was reading the Wiki on "LoadStrings" and it says you can convert a string value into a LUA code. So what I wanted to do was make a TextBox where the Player can write a LUA script in there, and make a LoadString script run it. But I don't know how to... And the script examples on the Wiki give me a error.

0
Did you try searching your problem on the site before asking this question? Just searching loadstring I found a lot of examples. OldPalHappy 1477 — 7y
0
Loadstring is recommended against to use, as it has vulnerabilities. TheeDeathCaster 2368 — 7y

1 answer

Log in to vote
0
Answered by
RubenKan 3615 Moderation Voter Administrator Community Moderator
7 years ago
Edited 7 years ago

Enable loadstring from the ServerScriptService, and call something like this.

local MyCodeString = [[
    for i=1,10 do 
        print(i) 
    end
]]
loadstring(MyCodeString)()

Just a heads up, Loadstring makes your place EXTREMELY vulnerable to hackers. Suggest to NOT USE LOADSTRING. (Atleast not in published work.)

0
There are instances where loadstring can be used safely, I believe. But overall I agree. OldPalHappy 1477 — 7y
Ad

Answer this question