How can I reference a key from a function inside the same dictionary where the key is at

I searched this but no one has the answer, Trying to make a custom tool system and I am storing every function for the tool equip and unequip inside a table


In this image im trying to access the [“Services”] key but I cant because theres no way to reference the start of the dictionary also im aware dictionaries have no herarchy so how can I do this.

you can either add in the function after the dictionary has been defined

local CustomToolLocalCode = {text = "this"}
CustomToolLocalCode.Equip = function()
    print(CustomToolLocalCode.text)
end)

or pass the dictionary itself as a parameter whenever it is ran

local CustomToolLocalCode = {
   Text = "this"
   CustomToolLocalCode.Equip = function(self)
       print(self.text)
   end)
}
CustomToolLocalCode.Equip(CustomToolLocalCode)
1 Like

Try using module scripts, ModuleScript

1 Like

its inside a module script

character limit grrrrrrrrr

BLOODY GENIOUS MATE!, marked as answer thank u sir.