How do I return a value in a dictionary from a modulescript?

local maps = {
	River =  {
		id = 1;
		name = 'Water';
		image = 'rbxassetid://11902152566';		
	Industrial = {
		id = 2;
		name = 'Meat';
		image = 'rbxassetid://11902230108';

To call the dictionary, I want to use the ‘id’ value inside the dictionary to identify it: module:getMapData(id). How do I make the module return the proper values?

1 Like

Iterate over the dictionary and compare the id properties:

for name, data in maps do
   if == ID then
      -- Compare the current id to the provided id in the function
      -- returns the index and the map data
      return name, data

arent modules only able to return a single value?

No, modules can return multiple values

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