Does __index only use '.' and not ':'?

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.

How I get the client
image

How I define it in my script
image

Error
image

Using : basically means you’re calling a function, so no, : is not detectable by __index.

1 Like

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

If you want something to happen when the function is called why don’t you write what will happen in the function or fire a bindable event?

1 Like

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:

Wrapping with metatables, or "How to alter the functionality of Roblox objects without touching them".

1 Like