Trying to make custom methods for Instance

Why doesn’t it set the name?

trueinst = Instance

eh = {}

	local trueobj =
	local okay = {}
	function okay:Way()
		local realobj = getmetatable(okay).__index
	setmetatable(okay, {__index = trueobj})
	return okay

Instance = setmetatable(eh, {__index = trueinst})

local eh ="Accessory")
eh.Name = "erer"

Does it print anything? If it does, what does it print?

you define methods outside of the declaration of the object, not inside

It prints the original name of “Accessory”.

If truobject would be a new instance, and okay would just be the index of that. Then realobj would also inherit the name of trueobj, which is just the ClassName of the object you tried to index. So index is returning the new instance’s name not the actual objects.

ᶜᵃⁿ ʸᵒᵘ ᵉˣᵖˡᵃᶦⁿ ᶦᵗ ᵐᵒʳᵉ ᶜˡᵉᵃʳˡʸ

Since okay is the index metamethod of trueobject which is a new instance of the ClassName you used in it would have the same name as the ClassName of whatever instance type you referenced with.

1 Like