How can I store variables in OOP

I made this script that stores the given value to the script that can be used later on but I’m not exactly sure how to re-use them later

local MissionFunction = {}
MissionFunction.__index = MissionFunction

function MissionFunction.new(Name, Description, Difficulty, XP, Credit)
	local Mission = {}
	setmetatable(Mission, Mission)
	
	Mission.CallTag = Name
	Mission.Description = Description
	Mission.Difficulty = Difficulty
	Mission.XP = XP
	Mission.Credit = Credit
	
	return Mission
end

function MissionFunction:Load(MissionLabel, DescriptionLabel, DifficultyLabel, XPLabel, CreditLabel)
	MissionLabel.Text = self.CallTag
end

return MissionFunction

It looks like you want to use MissionFunction as the metatable, so you should instead write
setmetatable(Mission, MissionFunction)

2 Likes

Once you do the above change, then you can do the following:

local MissionFunction = require(Path.To.Module)

local mission = MissionFunction.new('name', 'description', 'difficulty', 500)

print(mission.CallTag) --> 'name'