Greetings, I’ve run into a semi complex problem that I don’t quite know how to solve. I’m trying to create a custom module that can be used with a custom class, or directly.
This is the code I’ve got:
local GroupService = game:GetService("GroupService")
local Module = {}
Module.__index = Module
function Module.WrapPlayer(WrappedPlayer)
if WrappedPlayer:IsA("Player") then
--return WrappedPlayerFunctions
return setmetatable({}, Module)
else
warn(WrappedPlayer.." is not a 'Player' instance.")
return WrappedPlayer
end
end
function Module:GetRankInGroup(GroupId)
--local PlayerGroups = GroupService:GetGroupsAsync(WrappedPlayer.UserId)
print(self, GroupId)
end
return Module
The idea here is I could do
local WrappedPlayer = Module.WrapPlayer(Player)
WrappedPlayer:GetRankInGroup(1)
-- OR
Module.GetRankInGroup(Player, 1)
I’m clearly missing something here though. Anyone know what I need to do, and resources for further understanding?