Hi, I don't use Roblox but Love2d but this is by far the best video I found about OOP. I was looking into inheritance but this video just makes it crystal clear that this is far superior. Thank you so much for taking the time to make this.
Yep, the fact that the mentality was explained really set me on my place. It's absolutely amazing to think of inheritance of "this is this" and composition of "this has this". Just the way of thinking is completely clear and you can see that it's superior. A human is an animal? Why don't we act dumb then. A human has animal features. This makes much more sense.
Thanks for this video, been learning how to use OOP programming recently and it can get quite messy with the functions. Really nice to see someone who provides tutorials using OOP since it's really a great way to clean up your code.
I love this I love this I love this!!! I've just seen how Packages work and I know how Godot works so my mentality would be more like "let's use packages to construct classes instead". I want to be more visual about it instead of core-based because code requires you to read it. I want to see my structure. Anyway both your method and mine should be able to achieve the same goals - composition where by changing the components you change code everywhere. I find it much easier to understand less abstract concepts and ideas like having composition out of actual components and using them as if they are default Roblox instance classes.
dude, this is exactly what i was looking for! Inheritance is quite limiting and composition looks so much better. Stumbled upon this from devforum, great video!
B Ricey i love your content, after watching and learning your OOP series, what should we learn or do next? I feel stuck and honestly i dont know what to do.
I would love to see an updated oop video on metatables and modulescripts! And I want to see your new practices because I'm starting to get interested in Roblox development again because I never knew that Roblox was powerful enough to make abstract classes. Love your work
Its cool ... but DONT, by any means use ALWAYS composition. There are cases where it doesn't make sense and make you create lots of unnecessary modules. First check if TypeB is a TypeA (B can do all the things that A can, and can be replaced.), if not, then just extract in modules the things that you need from TypeA into TypeB. Also, you can use Both, and that's what I usually do a lot. For example: Vehicle (atributes: Name, color, speed, size) [methods: Move()] Car is a Vehicle(atributes: Engine, Wheels) Engine (Atributes: Capacity) [Methods: TurnOn(), TurnOff()] Wheel (Atributes: Color, size) Wings (Atributes: Color, size) Plane is a Vehicle(atributes: Engine, Wings) Bycicle is a Vehicle (Atributes: Wheels) In this example Vehicle is just an interface or an abstract class but the idea is that it can be upgraded with more unique methods that all vehicles will share.
Awesome video. Just one question, is there a way to use self object on the base table? Something like this: setmetatable({ using self in this table }, metatable) on the new method
Sadly, you can't. The workaround is using: local self = setmetatable({}, mt), and then in a line below saying: self.Model = self:MakeModel() or something
Great video! This has helped me understand OOP in a way that no other tutorials could. A question I have, however, is how I would apply this in a practical approach. Let's say I want the car to move forwards when I press 'W', using a LinearVelocity. The thing I am stuck on is: - Detecting key presses is done on the client, so how would I call the server method of 'Drive()' on the client, when you can't pass metatables through a remote event, and sending a remote event from Client > Server isn't viable, as I would be using RunService to detect when W is held, and then increase the speed the longer it is held, and obviously sending a remote event 60 times a second is not good Obviously I am not asking you to write the code for me, but an explanation of how I could go about this would be greatly appreicated. Either way, thank you for the great video!
@BRicey That's gonna cause loads of lag firing it 60 times a second, it needs to be done on the client. Atm I just don't use OOP for the client, and tbf it works fine but if I want to expand the code base its gonna be difficult
I am using your method to. create apples. But i keep getting new is not a valid member of ModuleScript "ServerScriptService.AppleModScript" - Server - appleTrigScript:2. Which coming from the SSS script called appleTrigScript on line 2 which is only 3 lines: local Apple = script.Parent.AppleModScript local A = Apple.new(workspace.farmQuestModel.AppleModel) A:Drive() Now of course the apple is not going to drive and have tires. But i put in the CFrame to move it there. But i cannot get past the not a valid member of the apple mod script which is put together just like Car in your video. where there is a: function Apple.new(appleModel). Any ideas
it works now but i have no idea why, i asked chatgpt for help and it gave me a code to copy and paste (it was the exact same as mine) but now it worked
Hi, I don't use Roblox but Love2d but this is by far the best video I found about OOP. I was looking into inheritance but this video just makes it crystal clear that this is far superior. Thank you so much for taking the time to make this.
That is absolutely amazing! Your very welcome! I'm glad I can get to people who are not only using roblox, but other engines
Yep, the fact that the mentality was explained really set me on my place. It's absolutely amazing to think of inheritance of "this is this" and composition of "this has this". Just the way of thinking is completely clear and you can see that it's superior. A human is an animal? Why don't we act dumb then. A human has animal features. This makes much more sense.
Thanks for this video, been learning how to use OOP programming recently and it can get quite messy with the functions. Really nice to see someone who provides tutorials using OOP since it's really a great way to clean up your code.
Simply explained. Great example as opposed to abstract concepts. Well done!
I love this I love this I love this!!!
I've just seen how Packages work and I know how Godot works so my mentality would be more like "let's use packages to construct classes instead". I want to be more visual about it instead of core-based because code requires you to read it. I want to see my structure. Anyway both your method and mine should be able to achieve the same goals - composition where by changing the components you change code everywhere.
I find it much easier to understand less abstract concepts and ideas like having composition out of actual components and using them as if they are default Roblox instance classes.
dude, this is exactly what i was looking for! Inheritance is quite limiting and composition looks so much better. Stumbled upon this from devforum, great video!
I asked for a video on composition last year and you finally did it, just wanna say great video and I really appreciate it.
Composition Sounds super cool! Glad i stumbled onto this video : D
This is why the Knit's Component Module is so awesome
other OOP tutorials was boring but this something else
B Ricey i love your content, after watching and learning your OOP series, what should we learn or do next?
I feel stuck and honestly i dont know what to do.
This is the knowledge we hunger for!
you always have what im looking for , you are amazing
Creating Classes with other Classes you say?
Hmmmmmmmm...
I just noticed your name lol
old videos, but timeless content lol. Currently in the process of cleaning up the code of my old game and this video was very useful
Glad I could help!
great example of how to implement OOP in Roblox!
because of you I learned how to use Metatables in module scripts. Thanks B Ricey!!
Glad I could help!
I would love to see an updated oop video on metatables and modulescripts! And I want to see your new practices because I'm starting to get interested in Roblox development again because I never knew that Roblox was powerful enough to make abstract classes. Love your work
HAPPY 2K SUBSCRIBERS!
Nice video! Very informative 😄
i fucking love you homie
Great vid! I'm trying to get my habbit into OOP.
so composition is just a bunch of little inheritances
Love your videos.
holy crap thanku i lov this method
it is kinda sad that there a no intellisense with OOP approaches in roblox studio :(
this still very confusing to me,why it overrides itself if i make 2 of them!?Isnt this whole point of OOP!?
AWESOME tutorial
Downside of composition, you need to make tons of simple classes
Its cool ... but
DONT, by any means use ALWAYS composition. There are cases where it doesn't make sense and make you create lots of unnecessary modules. First check if TypeB is a TypeA (B can do all the things that A can, and can be replaced.), if not, then just extract in modules the things that you need from TypeA into TypeB.
Also, you can use Both, and that's what I usually do a lot. For example:
Vehicle (atributes: Name, color, speed, size) [methods: Move()]
Car is a Vehicle(atributes: Engine, Wheels)
Engine (Atributes: Capacity) [Methods: TurnOn(), TurnOff()]
Wheel (Atributes: Color, size)
Wings (Atributes: Color, size)
Plane is a Vehicle(atributes: Engine, Wings)
Bycicle is a Vehicle (Atributes: Wheels)
In this example Vehicle is just an interface or an abstract class but the idea is that it can be upgraded with more unique methods that all vehicles will share.
Awesome video. Just one question, is there a way to use self object on the base table? Something like this: setmetatable({ using self in this table }, metatable) on the new method
Sadly, you can't. The workaround is using: local self = setmetatable({}, mt), and then in a line below saying: self.Model = self:MakeModel() or something
@@BRicey thanks I'm gonna try that
Great video! This has helped me understand OOP in a way that no other tutorials could. A question I have, however, is how I would apply this in a practical approach. Let's say I want the car to move forwards when I press 'W', using a LinearVelocity. The thing I am stuck on is:
- Detecting key presses is done on the client, so how would I call the server method of 'Drive()' on the client, when you can't pass metatables through a remote event, and sending a remote event from Client > Server isn't viable, as I would be using RunService to detect when W is held, and then increase the speed the longer it is held, and obviously sending a remote event 60 times a second is not good
Obviously I am not asking you to write the code for me, but an explanation of how I could go about this would be greatly appreicated.
Either way, thank you for the great video!
You could just use a proxy method, something on the server that receives the remote event and then runs the appropriate method on the class
@BRicey That's gonna cause loads of lag firing it 60 times a second, it needs to be done on the client. Atm I just don't use OOP for the client, and tbf it works fine but if I want to expand the code base its gonna be difficult
Yeah I wouldn’t fire it every second, only fire it for when it changes direction
@@BRicey i think changing it on the client is the best approach, due to the fact that tye client has network ownership so it would be lag free
@@hello-uw2qw yeah
Thanks
Can you make an on screen coordinates system?
Great video, it really helped me understand. Now all I have to do, is re-code my game from scratch using OOP lol
just try to integrate your codebase in the future with OOP, I wouldn't rewrite your game rn
I see someone watches Arjan Codes :)
I am using your method to. create apples. But i keep getting new is not a valid member of ModuleScript "ServerScriptService.AppleModScript" - Server - appleTrigScript:2. Which coming from the SSS script called appleTrigScript on line 2 which is only 3 lines: local Apple = script.Parent.AppleModScript
local A = Apple.new(workspace.farmQuestModel.AppleModel)
A:Drive()
Now of course the apple is not going to drive and have tires. But i put in the CFrame to move it there. But i cannot get past the not a valid member of the apple mod script which is put together just like Car in your video. where there is a: function Apple.new(appleModel). Any ideas
Found it. I was not using Require in statement above
Can you make another perlin noise vid cuz its outdated
What do u mean? I don’t think the api has changed.
@@BRicey maybe try doing the script again i think i got something wrong
can you please explain it further for me?
i get how it works but i don't really get why you would need to use it and in what cases should you do so
13:01 i keep getting this error: attempt to index nil with 'IsFlat', why?
it works now but i have no idea why, i asked chatgpt for help and it gave me a code to copy and paste (it was the exact same as mine) but now it worked
I have the same problem, for some reason the values of the tables are printing nil
How do you loop through a string? Like a for loop but instead of looping through a table it loops through a string
for i = 1, string.len(yourString) do
local char = string.char(i) -- do whatever you want with it.
end
@@BRicey thank you
Hello hello
Chunk minecraft in roblox plss ;c
B ricey do you know how to make tank? If you do please tell me
I made a crappy one in the past but I’ll do a tutorial on one in the future
Thank you
Tack!
Yeah!
E