Error while trying to create custom methods inside Instances

Hi, so im currently making a “base” for a game, but are running into some problems…
I want to somehow extend a Player instance, and add custom methods inside it.

But indexing it through metadata will just destroy functions like WaitForChild and FindFirstChild. And i can’t find any posts about how to fix it.

local plr = setmetatable({}, {__index = Player})
function plr:Test()
   plr:WaitForChild("PlayerGui") -- Will return error
end

I get this error: Expected ':' not '.' calling member function WaitForChild
And i’ve tried using: plr.WaitForChild(plr, ...)

function test(plr) should fix it if I understand correctly

I dont want “external” functions, i want it inside the Player…

I don’t think thats possible, but if I can ask, why do you need the function inside the player?

Last time i had external functions, it was very very very messy

Usually it is, I reccomend sorting it into one script and using the comment feature:

-- This is a comment

To order your functions and make it a little easier to read, or use a module script I guess.

Idk… Im new into this topic, but Player is a class, not an instance of a class.

You can grab the Player class and then add your custom methods to it. To not destroy functions like WaitForChild or FindFirstChild.

function plr:Test()
   self:WaitForChild("PlayerGui")
end

plr:Test()

Nope, i will just return a error
Test is not a valid member of Player "Players.Fr3ckzDK"

Just use a module script and insert a local script into StarterPlayerScripts, I don’t believe it can be done any other way.

Yeah, but serversided scripting using that, is where the mess will come

Why would you need to access a function in the client and the server? Just use a modulescript in replicated and serverstorage, no?

Ain’t what im saying. That using modulescripts on the client can work, but i would need to use external functions for all on the server, if it ain’t possible to create custom methods inside a Player

I don’t believe that’s possible, but you can definitley try.

I made a script that does a similar job to what you’re asking, a while back:

Nahh!! Damn it works, you’re da goat!