Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why does only one script work? I do not understand the LUA help. (Object orientated)

Asked by 4 years ago
account = {
    balance = 10; 

        Withdraw = function(self,v)
            if v < account.balance then
                self.balance = self.balance - v
                print(account.balance)
            end
        end

}

account:Withdraw(5)
account = {
    balance = 10; 

        Withdraw = function(self,v)
            if v < account.balance then
                account.balance = account.balance - v
                print(account.balance)
            end
        end

}

account:Withdraw(5)

Why does the top one work, but not the bottom one?

0
cuz your taking away the - v Balance you've made a function called self,v so your removing the self,v function then it cant o mart8888888 0 — 4y

Answer this question