Player:GetAccountId() is passed a table argument

39 views Asked by At

I've been trying to use

local function TestFunction(event, player, command)
    local accountId = Player:GetAccountId()
end

whichs 2nd line was copied straight from the ElunaLua wiki. On execcution I received the error

calling 'GetAccountName' on bad self (bad argument : Player expected, got table)

I suspected the "Player" to be a global argument, wondering how it can be a table and how to use said table?

1

There are 1 answers

0
Honey55 On

"Player" is actually a global table that holds the functions you can use on a Player type variable. So that player has all functions in "Player" table. This is why doing Player:GetAccountId() caused a bit of a different error than something like Player variable not existing.

To make it work, i used "player:GetAccountId()" instead of a capital P. This passes the method the variable named "player".