Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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.

2 comments

0

Did you try searching your problem on the site before asking this question? Just searching loadstring I found a lot of examples.

0

Loadstring is recommended against to use, as it has vulnerabilities.

1 answer

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.)

1 comment

0

There are instances where loadstring can be used safely, I believe. But overall I agree.

This discussion is preserved as it was. New answers, comments, and votes are closed.