I’m trying to make some sort of messaging service heavily inspired by the discord API but when trying to get the Player’s mouse (which I have named ‘Client’) I have a table of custom properties and use __index as the player’s instance.
I tried doing Client:GetMouse() and I expected the __index event to fire and return Player:GetMouse() but it seems to be doing Player.GetMouse() I haven’t used metatables in a while so is there a metatable subsitute for __index: I know I could just add a function to the origional table that returns the mouse but I’m just wondering.
So is there any fixes to this or will I just have to add it to the actual table?
local client = Clients.LocalPlayer
local arg = {
username = client.Name,
id = client.UserId,
avatar = getAvatar(client),
On = Events.On.Event
}
function arg:GetMouse()
return client:GetMouse()
end
This is incorrect, using “:” is detectable by the __index method. Wrapping objects with roblox instances is a bit tricky, but this tutorial goes over how it can be achieved: