Can you call a method like that way?

I’m doing a function inside a Module Script that gets the player’s friends:

function Functions:GetFriends(localplr):number
	local tabela = {}
	local plrs = plrs:GetPlayers()

	for _, v in pairs(plrs) do
		local UserId = v.UserId
		local IsFriendWith = localplr:IsFriendsWith(UserId) and Tabelas.Armazem.tableinsert(tabela, v)
	end 

	return #tabela
end

Is it possible to call this function like that, for instance:

game:GetService("Players"):GetFriends()

If yes, how?

1 Like

I suppose you may need to use self? But I have doubts about the usage of self and even self is.

What are your intentions?
What is this line of code supossed to do?

game:GetService("Players"):GetFriends()
2 Likes

I’m trying to call the module function to something similar to that, like:

game.Players:GetPlayers()

It has the instance:Function().

1 Like

when doing instance:Function() you are just doing instance.Function(instance), which is used in OOP to be able to access self keyword, if your function is not on an OOP class or doesn’t require this, there is no reason you should seek for it to be called that way.

1 Like

That’s because I’d be creating a new function “inside” the instance, and it would be convenient for me

1 Like