How to get data with the same name in a modulescript?

Pretty stupid question, but i’d like to know how to require some data from a Modulescript, while it has the same name as the required data by a script. (I’m making a event system like Rise of Nations and HOI4)

Module:

local module = {}

--//Economic Boom

local economic_boom = {
	event_name = "Economic Boom!",
	event_desc = "PUSH IT TO THE LIMIT!"
}

--//Functions

function module.GetEventName(Event)
	return(Event.event_name)
end

return module

Script:

local module = require(game.ReplicatedStorage.Events.Generic.Economic)

print(module.GetEventName(“economic_boom”))

2 Likes

You can store events in a dictionary and access them with a key, like the string “economic_boom”.

local events = {
	economic_boom = {
		event_name = "Economic Boom!",
		event_desc = "PUSH IT TO THE LIMIT!"
	}
}

function module.GetEventName(key)
	local event = events[key]
	if event then
		return events[key].event_name
	end
end
4 Likes

That worked perfectly! Thank you very much!