local module = {}
function module.new(CarType)
local data = setmetatable({},{
__index = module
})
data.Speed = 10
data.CarType = CarType
return data
end
function module:Boost()
self.Speed = self.Speed + 1 --why does is self the data you returned in the constructor function?
end
return module
--Server script
local module = require(script.Parent:WaitForChild("Module"))
local car = module.new("idk")
car:Boost()
COMMUNITY QUESTION
In OOP why does this return the table you return?
0 answers
No public answers were preserved for this question.
This discussion is preserved as it was. New answers, comments, and votes are closed.

5 comments
you had a seizure with that comment on line 14 "why does is self the data you returned in the constructor function"
^ lol
oops
Why is self the data you returned in the constructor function
Do you know Python? self is used to refer to the Class that contains the given methods or your case here the functions, so "self" refers to "module". anytime you create a new function, "self" is automatically given in ROBLOX's Lua API, so every function really is function module.Name(self)