This is my first time posting on the devforum, so sorry if this isn’t posted in the right category
Anyways, so I’m a beginner at scripting, but I have a decent grasp on certain programming concepts like variables and functions and stuff like that.
So I decided to learn OOP on roblox, and I managed to make my own constructor function that creates a new part based on the parameters that are passed to the function.
This is the code:
-- modulescript
brick = {}
brick.__index = brick
function brick.new(position, transparency)
local newBrick = {}
setmetatable(newBrick, brick)
newBrick.Position = position
newBrick.Transparency = transparency
return newBrick
end
return brick
The brick.new() function seems to work, but I still can’t figure out how to actually spawn a new part, and then assign the properties of the object to the actual part itself.
I’ve read a bunch of devforum threads regarding OOP but I still can’t seem to actually understand how to apply it to my own games
So if anybody could help me, that would be great