Anybody can help me about understanding basic OOP thingy?

how can i make basic OOP thingy ?

Come on man. You really think this thread is going to go anywhere with a title like that.

i dont know dude xD :grinning:

The search feature is pretty useful for that. Try searching for OOP or Object Oriented Programming. A really good one is this: All about Object Oriented Programming

2 Likes

Here’s an example of a Class using an Object Oriented style in Luau form.

local Account = {
	balance = 0
}
Account.mt = {
	__index = Account
}

function Account.new(balance)
	local self = setmetatable({}, Account.mt)
	self.balance = balance
	return self
end

function Account:Withdraw(amount)
	self.balance = self.balance + amount
end

function Account:Deposit(amount)
	self.balance = self.balance - amount
end

local a1 = Account.new()
local a2 = Account.new(100)
print(a1.balance) --> outputs 0
print(a2.balance) --> outputs 100

Reading through the Metatables article should help you as well.

1 Like