✓ Accepted answer
Rarely is loadstring a good option
You use loadstring when you need something to be done on demand, but you don't have any idea what that code would be. For example -- Script Builders -- since you cannot make some function which will account for everything people want to do, you have no choice but to just let them execute arbitrary Lua.
Other things that might use it:
- What players say (like Script Builders)
- Files / StringValue resources
- Saved data (DataStores, HttpGet)
Note that loadstring is brittle, and not safe (a simple workspace:BreakJoints() will ruin everything else). It isn't a good solution.
For instance, to make parts, like in that example, it would be better to serialize information about it rather than actually use code:
Part,game.Workspace,Anchored=true
and then parse that instead.