Self not working in functions?

When I use colons for constructing functions, I always have to manually input the self parameter. I thought that is automatically inputted? Maybe I am being stupid but I thought it’d always fill automatically

f = {}

function f:poopy(self, param)
	print(param)
end

f:poopy('hello!') --> nil :(

thx

iirc when you make a funciton with “:” you dont need to specify “self” as an argument
so it would be:

f = {}

function f:poopy(param)
	print(param)
end

f:poopy('hello!')
3 Likes

I think self can only be used like this

typed on my phone so this might not work

f = {}

Local fMt = {__index = f}

Function f.new()
      Local self = {}
      Return setmetable(self, fMt)
End

inside a “:” function, self is automatically defined