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

What is loadstring? What can it be used for?

Asked by 4 years ago

First of all, what is loadstring? I've heard of it a lot and I have no idea what it is. Second of all, what can loadstring be used for... I think it can be useful but I don't know what it can be useful for??

1 answer

Log in to vote
0
Answered by
ArtBlart 533 Moderation Voter
4 years ago

Loadstring (Listed under this devforum article) is a Lua Global that can allow for arbitrary code execution. Essentially what it does is it takes a string value and converts it into a function. By default, it is disabled on your games because of major security concerns with allowing server scripts to run arbitrary code. You cannot access this property by script, as it will error out. Here is a quick example of what you can do with loadstring:

loadstring("print('hi')")()

OUTPUT: "hi"

As you can see, it can be useful in some cases, where you dont know what code you will be running. I.E: Script Builder Games. However, a single error in securing your loadstrings could cause a catastrophic failure for the integrity of your game against exploiters, as essentially, they could gain access to running any serversided code they want, meaning they could destroy servers or mess around with things in your game.

Hope this helps! If you have any further questions feel free to comment or look things up on the devforum.

Ad

Answer this question