That's what it's all about! I just yesterday wanted to make a module with timers so I can easily start and stop them like Timer:Continue() and Timer:Pause() and at the same time have several of them with different speeds and time remaining, but I looked for tutorials about it but never figured it out... And today you made a video about it! Your videos are very helpful and so easy to understand! That I finally understood what this scary creature is - metatable! Thank you so much, GnomeCode, for being you!))))
This completely described what metatable is for me cause I literally never used it before even though I’m an experienced scripter and it seems like it’ll help me later on ❤
I don't know why but i never had much of a issue with metatables. All i saw metamethods as was just some specific events which you can set a callback to
Hey gnomeCode im watching you since maybe episode 5 of tower defense tutorial and you inspired to actually learn programming and now im learning c# and advanced blender stuff and i just want to say thank you because if not you i would stop at just making a free model obby and quit and probably forget about programming
This video was suuuuper helpful! I've been wondering so long why some things use a . or a : and if it was something I can use myself or if it was only for built in roblox functions. This will help so much because I have a need for possibly dozens to hundreds of similar objects with varied stats
I appreciate you breaking things down in the manner you do. You’re by far the best teacher when it comes to learning Lua’s programming language. I’ve learned other programming languages in college. So I appreciate your style.
this is nice, but i would probably do something different for the .new() function. when you accept a table as an input for the new function, lua doesn't know what it's expecting. you should rather accept the individual attributes in the new function instead of a table. for example, this is more how i would do the new function function Food.new(name, color, description, price, quantity) local newFood = setmetatable({}, Food) newFood.Name = name newFood.Color = color newFood.Description = description newFood.Price = price newFood.Quantity = quantity return newFood end this will let the lua compiler verify that you are passing in valid arguments instead of garbage. You could before do something like "Food.new({garbage = "this is garbage"})" and it wouldn't complain. Sure, it works, but it wastes memory and there is no point. additionally, it will tell people what arguments the function is expecting when you call it. if it just has a table as an argument, that could be anything. but this will tell you exactly what you need to put in when you're typing it. and also you have to type more code when you're passing in a table. i do see a potential reason the other .new() function would be used, but it might be more appropriate to name it something like ".fromTable()" or something like that. i do like the video though, it does explain the basics of object oriented programming, but i think a bit more explanation on methods would help as well. i can see how they would get confusing.
I really think this kind of video is valuable. It would be great if you could also create videos about other concepts or skills that are useful while writing scripts or good to know
Very helpful video! Thanks for making it. Could you continue your doors series? I really enjoy watching it, I learn a lot from it. (I don't write it down)
Okay. So here's what im getting or learn't. correct me if im wrong. MetaTables allow u to manipulate values without having to define a new table variable. It has a default that if u send another table of values will check the MainTable to see if anything is missing and assign it if needed. EG if ur default has the quantity value and u send over just the name itll assign the default quantity. The index thing connects the main table to check if something else is already in there? or is it what connects the defaulttable to the new one to see if there is any values needed. --Personal Test-- I send over a food table with a new value of HPR(hpregen) and the table didnt break but instead treated it like it was already apart of it which I THINK IS VERY HELPFUL FOR MANY THINGS!! (If im wrong i don't mind being corrected im trying to learn, if im offmark or missing information please inform me :D)
Gnome I know you probably won’t see this but remember in your tower defence game I know you probably can’t help but with the collision with the player aren’t working is there any idea why they aren’t?
Yay ur back with another vid. Can you make a series on how to make a Murder Mystery game, or and updated version of keys that u did in teddy caus putting the key in the tools didnt work for me. It make u break 90k but idk tho
I really dont understand this Food.__index = Food. Like if you are searching a table and you cant find indexed element you search it agian in infinite loop?
Hey gnomecode, I know you probably won’t see this, but in the slim chance you do, what is going to happen with the doors series, if you don’t mind me asking, I just wanna know if you will be continuing it.
Is there any way to overload constructors? For example; local fruit = Fruit.new(“Apple”, “a fruit!”) local fruit = Fruit.new(“a fruit!”) and the second option uses the name parameter (apple) from the index table instead of putting “a fruit” as the name parameter?
But the bit about setting the metatable to itself is... I don't understand why the changes in the code reflect that. Wouldn't changing the index rule to 'food' be enough? Why get rid of the food prototype table? Do you HAVE to get rid of it? Ok so you don't. But the advantage is not having to look up another table. As in... You get all of the values via the food.new constructor if you want, filled values and default. While you can only get specific values or the prototype table the other way. Right. Oh AND you can't use self otherwise. Ok... How does the colon know there is an object(table?) that's got a metatable...? Wait do you need to first do the constructor then. Yeah. Ok. I see. But isn't this only useful if you add new layers of inheritance. Pasta, fruit, stews. And then I guess... You can pass in randomised values? No I still don't understand the point of it... Why have default values and functions? but it is very neat.
Hi GnomeCode! I Was wondering if you could make a tutorial on making a basketball game in roblox. I would really appreciate it, because there are no tutorials on it, and I think you could easily make one. Thanks!
Hello, I have a video request. I was wondering if you could make a video explaining how to make it so during a game, any player can change some text, they are expected to type a decal id, then a script detects the id typed by the player, and changes a decal or image on a part or gui.
It's simple but does require a video to make. Here's a sample script (Please indent the lines as I was writing this code on mobile): local InputBox = script.Parent:WaitForChild("InputBox") local ChangeDecalId = script.Parent:WaitForChild("ChangeDecalId") local ChangeDecalImageEvent = game.ReplicatedStorage:WaitForChild("ChangeDecalImage") ChangeDecalId.Activated:Connect(function() local id = tonumber(InputBox.Text) if id == nil then return else ChangeDecalImage:FireServer("rbxassetid://"..tostring(id)) end end)
hey Gnome code I hope you see this message but, I have problems with the piggy game, I tried learning from the uncopylocked game but nothing could beat the way you explain, I've been struggling for I while now. if your not gnome code please like so gnome code can see this. your truly -ToastFilms
The explanation of __index is really what helped me understand the actual flow of what’s happening where I couldn’t before, thanks a ton❤. Basically, the module is just a bunch of default values for a table
@@Hadev123 -compared to other languages commonly used by game frameworks and engines lua is a shitshow and luau is an even bigger shitshow. the only good thing is that its quite performant. but syntax and pattern wise, the fact that you have to use metatables for something simple as OOP is convoluted and doesnt even work properly with luau's type checking system. hopefully luau will add syntactic sugar for class declaration someday
Showing 'workspace' with its methods and functions really gave me the spark of understanding OOP more.. thanks
That's what it's all about! I just yesterday wanted to make a module with timers so I can easily start and stop them like Timer:Continue() and Timer:Pause() and at the same time have several of them with different speeds and time remaining, but I looked for tutorials about it but never figured it out... And today you made a video about it! Your videos are very helpful and so easy to understand! That I finally understood what this scary creature is - metatable! Thank you so much, GnomeCode, for being you!))))
This completely described what metatable is for me cause I literally never used it before even though I’m an experienced scripter and it seems like it’ll help me later on ❤
metatables are so complicated to the point i dont even care about them
@@mysyvcic they are REALLY useful in the right situations tho
@Magic_Blox same bro
I don't know why but i never had much of a issue with metatables. All i saw metamethods as was just some specific events which you can set a callback to
@@mysyvcic exactly like its just easier not even using them lmao
Hey gnomeCode im watching you since maybe episode 5 of tower defense tutorial and you inspired to actually learn programming and now im learning c# and advanced blender stuff and i just want to say thank you because if not you i would stop at just making a free model obby and quit and probably forget about programming
This video was suuuuper helpful! I've been wondering so long why some things use a . or a : and if it was something I can use myself or if it was only for built in roblox functions.
This will help so much because I have a need for possibly dozens to hundreds of similar objects with varied stats
thank you so much gnomecode, ive been trying to learn about oop for so long, and this finally put logic in my head
hmmmmmmmmm
I appreciate you breaking things down in the manner you do. You’re by far the best teacher when it comes to learning Lua’s programming language. I’ve learned other programming languages in college. So I appreciate your style.
Super useful! I need to use module scripts more often, I always forget how useful they are.
This video is really interesting and helpful, thanks GnomeCode.
Yay an another vid, TYSM gnomecode for all things you make for us 👍
ok this was a video I actually needed
same here
I was literally saying “oop” right before you said it
this is 100% the best channel for learning scripting. This helped me so much
Love these videos. Thanks gnome code!
Great beginner tutorials you are creating!
Nice I’ve been wanting to learn metatables for a while!
This really did help me on what metatables are!
Exactly what I was thinking of learning next!
thank you, now i understand how metatables are working
this is nice, but i would probably do something different for the .new() function.
when you accept a table as an input for the new function, lua doesn't know what it's expecting. you should rather accept the individual attributes in the new function instead of a table. for example, this is more how i would do the new function
function Food.new(name, color, description, price, quantity)
local newFood = setmetatable({}, Food)
newFood.Name = name
newFood.Color = color
newFood.Description = description
newFood.Price = price
newFood.Quantity = quantity
return newFood
end
this will let the lua compiler verify that you are passing in valid arguments instead of garbage. You could before do something like "Food.new({garbage = "this is garbage"})" and it wouldn't complain. Sure, it works, but it wastes memory and there is no point.
additionally, it will tell people what arguments the function is expecting when you call it. if it just has a table as an argument, that could be anything. but this will tell you exactly what you need to put in when you're typing it. and also you have to type more code when you're passing in a table.
i do see a potential reason the other .new() function would be used, but it might be more appropriate to name it something like ".fromTable()" or something like that.
i do like the video though, it does explain the basics of object oriented programming, but i think a bit more explanation on methods would help as well. i can see how they would get confusing.
But isn't the whole point of metatables and metamethods is to accept whatever you want?
Food.new({}) in the table looks working but it's just waste of memory.
Althought server contains of memory and client doesn't uses that much performance.
I am 2 seconds in the the video and already love it! It helped me cure my illness!
Wonderful
1 year and bro has NOT noticed the typo
?
@@appledoesrandomstuff title says "object oriented progamming"
This video is actually incredibly good
I really think this kind of video is valuable. It would be great if you could also create videos about other concepts or skills that are useful while writing scripts or good to know
Maybe completing the collection by also doing a tutorial on Functional Programming?
Very helpful video! Thanks for making it.
Could you continue your doors series? I really enjoy watching it, I learn a lot from it. (I don't write it down)
I learned about OOP almost 5 years ago.
w vid bro this finally solved my confusion (especially metatables lol)
Thx man! I know how to use self now since I get confused all the time
Okay. So here's what im getting or learn't. correct me if im wrong.
MetaTables allow u to manipulate values without having to define a new table variable. It has a default that if u send another table of values will check the MainTable to see if anything is missing and assign it if needed. EG if ur default has the quantity value and u send over just the name itll assign the default quantity.
The index thing connects the main table to check if something else is already in there? or is it what connects the defaulttable to the new one to see if there is any values needed.
--Personal Test--
I send over a food table with a new value of HPR(hpregen) and the table didnt break but instead treated it like it was already apart of it which I THINK IS VERY HELPFUL FOR MANY THINGS!!
(If im wrong i don't mind being corrected im trying to learn, if im offmark or missing information please inform me :D)
By far the best OOP video on roblox ever made. 💖
no way i see a gnome code video 8 minutes after its uploaded 🥳
Nice beginner tutorials you are creating!
Gnome I know you probably won’t see this but remember in your tower defence game I know you probably can’t help but with the collision with the player aren’t working is there any idea why they aren’t?
My brain just randomly clicked on how to make something in a FPS framework, I'm gonna have made 50 of those before i even publish a game
Hey man, It would be awesome if you made a tutorial but just dedicated to the .__index part. For me, that's the hardest part to grasp in this video.
how to make a purchase prompt for catalog items and clothes appear when text button gui is clicked
Santa tell me...
Will you get in beeeed?
So metatables are only useful for storing functions and heavily orginize your code.
Yeah?
Yay ur back with another vid. Can you make a series on how to make a Murder Mystery game, or and updated version of keys that u did in teddy caus putting the key in the tools didnt work for me. It make u break 90k but idk tho
Idea:💡 Can you please make a video on how to script plugins?
gnome please stop avoiding the doors tutorial
that was very helpful thank you
I really dont understand this Food.__index = Food. Like if you are searching a table and you cant find indexed element you search it agian in infinite loop?
I know you already did a piggy series, but you should make one of those maze games like cheese escape
Great video
I'm learning it in my school rn :D
i dont understand how does it know that you can call the eat function for myOtherFood
Hey gnomecode, I know you probably won’t see this, but in the slim chance you do, what is going to happen with the doors series, if you don’t mind me asking, I just wanna know if you will be continuing it.
I want to see a hungry pig tutorial video!
I didnt understand very well because we could do all of this stuff just using model function why did we use OOP
Sometimes I don't get the difference between the dot operator and the colon operator. Why is it Instance.new() and not Instance:new() ?
Is there any way to overload constructors? For example;
local fruit = Fruit.new(“Apple”, “a fruit!”)
local fruit = Fruit.new(“a fruit!”)
and the second option uses the name parameter (apple) from the index table instead of putting “a fruit” as the name parameter?
Not sure how that would work as Lua is not a typed language.
Use metatable over the new constructor ;)
Can you do inheritance and composition?
why use metables when you can still attach functions to tables
usually your videos are the best... but we couldn't follow this one too well.
what is the point of saying ..index for the "Food" table when you can instead just set the "FoodPrototype" as a metatable
When I watch this without even being able to code anything except for functions.😮
We need a tower defense tutorial for skins lol but im pretty sure you are done with that series
Thanks!
wow, this might be what i need to buss
That's what I needed
Thank you
But the bit about setting the metatable to itself is... I don't understand why the changes in the code reflect that. Wouldn't changing the index rule to 'food' be enough? Why get rid of the food prototype table? Do you HAVE to get rid of it? Ok so you don't. But the advantage is not having to look up another table. As in... You get all of the values via the food.new constructor if you want, filled values and default. While you can only get specific values or the prototype table the other way. Right. Oh AND you can't use self otherwise. Ok... How does the colon know there is an object(table?) that's got a metatable...? Wait do you need to first do the constructor then. Yeah. Ok. I see. But isn't this only useful if you add new layers of inheritance. Pasta, fruit, stews. And then I guess... You can pass in randomised values? No I still don't understand the point of it... Why have default values and functions? but it is very neat.
You Do!
Could you please make a breakdown for creating party system thank you
is the metatable same as inheritance in c++ oop?
when's the next gnomejam? I really want to know so I don't enter late like last time
thank you
Object oriented programming makes my head hurt in funny place
yo gnomecode can you make a tut how to make a badge giver when you click f9 and then on server and type a code that gives the player the bagde?
Hi GnomeCode! I Was wondering if you could make a tutorial on making a basketball game in roblox. I would really appreciate it, because there are no tutorials on it, and I think you could easily make one. Thanks!
Hello, I have a video request.
I was wondering if you could make a video explaining how to make it so during a game, any player can change some text, they are expected to type a decal id, then a script detects the id typed by the player, and changes a decal or image on a part or gui.
It's simple but does require a video to make. Here's a sample script (Please indent the lines as I was writing this code on mobile):
local InputBox = script.Parent:WaitForChild("InputBox")
local ChangeDecalId = script.Parent:WaitForChild("ChangeDecalId")
local ChangeDecalImageEvent = game.ReplicatedStorage:WaitForChild("ChangeDecalImage")
ChangeDecalId.Activated:Connect(function()
local id = tonumber(InputBox.Text)
if id == nil then
return
else
ChangeDecalImage:FireServer("rbxassetid://"..tostring(id))
end
end)
So useful!
love ur vids 😂
hey Gnome code I hope you see this message but, I have problems with the piggy game, I tried learning from the uncopylocked game but nothing could beat the way you explain, I've been struggling for I while now.
if your not gnome code please like so gnome code can see this.
your truly -ToastFilms
What are the usages?
Gnome code great
The explanation of __index is really what helped me understand the actual flow of what’s happening where I couldn’t before, thanks a ton❤. Basically, the module is just a bunch of default values for a table
bro holy fucking shit i didnt even know it was possible to drag such a simple concept on this longf
@@MarkDSnutts ?
No swearing!
video 2 of asking for you to review retro studio again because it now has coding and a lot more games
When is the next how to make doors in roblox studio?
best tutorial i ever found❤❤
For real
Hey, when doors tutorials?
1 year later - It's finally here!
@@GnomeCode thanks
Gnome code can u please start a teddi series nobody wil so can u
Cover more tutorial topics
Can you record how to make Cheese escape system and Tower defense game (your tutorials is outdated) (Day 1 Waiting)
I'm still confused.
are you still confused?
@@lembarkii8669 I've got the hang of it now :)
im kinda disappointed he ditched the doors series :(
yo its been a while
moral of the lesson: just use python
It’s Lua in 100 seconds I think it’s actually a pretty good language
@@Hadev123 -compared to other languages commonly used by game frameworks and engines lua is a shitshow and luau is an even bigger shitshow. the only good thing is that its quite performant. but syntax and pattern wise, the fact that you have to use metatables for something simple as OOP is convoluted and doesnt even work properly with luau's type checking system. hopefully luau will add syntactic sugar for class declaration someday
Can you pleas make Skins for the Tower Defense. i need they so much so pleas
upload more, like do a tds game part 2 tutorials
Cool video
and i oop-
😐
and i oop
do doors tutorial part 9
Did I just watch a... Roblox programming tutorial? What langauge is it based on btw? Looks like Python but I'm curious
Roblox uses a modified version of the Lua programming language
Alright, thanks! I'm not into Roblox so I probably won't watch many of videos but good luck with your youtube career!
Cool, but we need more tutorial series
my bad if your tired of doors comments but why is it taking so long? (I'm not RUSHing you)
only in roblox would the average programmer need to learn what OOP is lol