Is there a way to turn a string into a reference?

That is beyond the point. I can safely say that, from a maintainability and security perspective, loadstring and its equivalents in any other language are not to be used under any circumstances in any environment with a non-developer end user and even then itā€™s not a good idea

Can you explain what this means? I donā€™t get it.

Letā€™s assume youā€™re trying to make a developer product. The only people touching the code will be developers, and likewise it can only affect the developer using it. Realistically, this would be something similar to a repl or some non-production precompiler / weird type checker that gets its types from runtime information. Maybe, in that environment, loadstring could be used. It still would not be advised, and is likely outside of the of any product deployed through Roblox.

In essence, ā€œnon-developer end userā€ means ā€œat some point the code will affect someone who is not a developerā€

That is false,

loadstring() will allow you to execute strings as if they were code.

Users can send strings from client to server through RemoteFunctions, if present.
They could then be executed through some function and modify structures like Datastores etc.

This is how loadstring() is used to exploit, whatever is contained in the string can run as code on the Server.

Please take a look into OOP. Not only will it help you with Lua code, it will also help you with many other languages. I became a much better programmer when I started listening to my professors about proper layout of code.

simply put, if you want to make a coffee with different flavors or what have you, you could do a module script with:

module script:

coffee = {};

-- + coffee.new(typeOfCoffee: string)
coffee.new = (function(typeOfCoffee)
	local self = {};
	self.typeOfCoffee = "";

	-- + coffe:getTypeOfCoffee(): string
	function self:getTypeOfCoffee()
		return self.typeOfCoffee
	end

	--constructor
	do
		self.typeOfCoffee = typeOfCoffee
	end

	return self;
end)

in another script:

local coffee = require(ModuleScript);

local myBrew = coffee.new("Espresso");

print(myBrew:getTypeOfCoffee()) -> Espresso

The sooner you get more comfortable with OOP, the easier you will be able to create complicated creations with multiple different types of classes.