Hello peoples. I've been making a game called Zombie Tower Defense for the past few weeks and I've run into many problems along the way there is one error in my script that really confused me. I found a solution to my problem but it makes no sense to me so I was hoping someone from the community could help me solve it.

From what I do know, the nano repair system is the "function" value and without it the script works perfectly.

Here was the fix before I explain the problem:

local module = {
	
	stuff = {
		expMissileLauncher = {
			Name = "TML";
			CashPerSecond = 35;
			BuildingTime = 100;
			Object = game:GetService("ServerStorage").Resources:WaitForChild("TML");
		};
		
		
		expNanoRepairSystem = {
			Name = "ENRS";
			CashPerSecond = 250;
			BuildingTime = 60;
			Object = game:GetService("ServerStorage").Resources:WaitForChild("ENRS");
		};
};
	};


return module

Here is the config module:

local module = {
	
	
		expMissileLauncher = {
			Name = "TML";
			CashPerSecond = 35;
			BuildingTime = 100;
			Object = game:GetService("ServerStorage").Resources:WaitForChild("TML");
		};
		
		
		expNanoRepairSystem = {
			Name = "ENRS";
			CashPerSecond = 250;
			BuildingTime = 60;
			Object = game:GetService("ServerStorage").Resources:WaitForChild("ENRS");
		};
	};


return module

Here is the part of the server script that should work perfectly but doesn't.

function getObject(name)
	print(config)
	
	for _,v in pairs(config) do	
		warn(v)
			 
		if v.Name == name then
			return {tab=v, o=v.Object}
		end
	end
end

-- 76: attempt to index local 'v' (a function value)

Like I said, this makes no sense to me so I don't know what more to say. Leave a comment if you need something.

2 comments

0

don't you need to require(v)? or did you already do that?

0

No. You don 't need a require(v)