Cant reference module varaibles

local getString = target.Parent:FindFirstChild("Barracks") or target.Parent:FindFirstChild("Uttility")
		if getString then
			print(getString, getString.Value)

			local cloneTroopMenu = troopMenu:Clone()
			cloneTroopMenu.Parent = target.Parent
			cloneTroopMenu.Adornee = target.Parent
			
			local category = getString
			local buildingNumber = getString.Value
			
			local getBuildingData = mainModule[category]
			warn(category)
			warn(getBuildingData)
		--	local createTroopButtons = Instance.new("ImageButton")
		end

how is it warning nil on getBuildingData if the string buildingNumber prints Barracks and inside mainModule there is a variable Barracks

local module = {	
	
	Barracks = {
		["Building1"] = {
			Name = "Normal Barrack",
			Price = 2000,
			Model = buildingsFolder.Barracks.NormalBarrack,
... (module is longer but example)
2 Likes

Did you remember to add the ‘return module’ part at the end of the module script? Also, did you require the module correctly in your script?

3 Likes

category is an instance

maybe you meant category.Name

3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.