Creating methods for core objects

So recently I tried making the jailbreak vehicle system, and I wanted to add a method to the player who tries to enter their vehicle (plr:OwnsVehicle(v)). However I’m not sure how to do this as the player is a core object and the scripts aren’t modifiable. Is there a way to do this?

You cant add a function to a class (sadly) so you will have to create your own class system using OOP (or Object Oriented Porgramming), and have it remain constant until the player leaves the game.
So when loading in the data of the player, store it somewhere you can reference, then use said function to check if they have said value in their data.

If you’re interested in learning more about OOP, I recommend these sources:

OOP Forum Post
OOP Video by GnomeCode
Roblox Documentation on Metatables (Covers OOP related items)

I’ve worked with oop a lot before but I’ve never tried actually making a new class for a core object.

So what you mean is I supply all player data to the class made for them when they join?

Correct, this is so you have a general place to reference and control how things interact with the player, whether it be purchasing an object, or checking if they have a setting enabled.

If its something needed for all Players and Server, try using a SharedTable, which replicates table information from the Server to the clients, and can be access on any script using SharedTableRegistry

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.