(sorry for bad english)
Hello, I’m new to metatables and I’m having a bit of problem of how would I go about something. So let’s say I made cars with metatables then put them in the workspace, now when players get near a car, it will show a GUI (Press E to drive), if they press it, do something like Car:Enter(player)
etc… but idk how would I get the car’s metatable to do that. Is there a way to do this?
What you are trying to do is write OO (Object Orientated) Code.
It may help you to store the car objects in a table and when a car is interacted, find that metatable in the table and then run the methods off that.
There are quite a few resources to help you get started with OOP:
Being honest, I think you’re confused about what a metatable is.
A metatable, at its most simple abstraction, is simply a hidden table attached to every table you make. Every table has a metatable. They honestly aren’t very useful for most applications, and it’s advisable if you’re a newcomer to programming to avoid them unless you are truly familiar with how they work, and if there are better alternatives.
You will need to script this functionality with Lua, which is the native scripting Language Roblox uses. If you’d like to make GUIs, you’ll have to do this with the object explorer / scripts - perhaps you might find this article: Intro to GUIs helpful.