keys9
Newcomer
- Joined
- Nov 5, 2021
- Messages
- 1
- Reaction score
- 0
Hello, I am new to Roblox coding and have a question about why I am getting the following error when I run the test server:
I omitted what I believe to be irrelevant parts of the code. Basically when BoardQueue:addPlayer is called I get the above error. I expect it to print the value of isReady in the instance of my BoardQueue class but instead I get that error. I am very confused because I am using self in a : function with the name of the class I Want self to refere to in front of the : . Forgive me if this is a newbie question as I am new to Lua.
Code:
isReady is not a valid member of Player "Players.Player1"
I omitted what I believe to be irrelevant parts of the code. Basically when BoardQueue:addPlayer is called I get the above error. I expect it to print the value of isReady in the instance of my BoardQueue class but instead I get that error. I am very confused because I am using self in a : function with the name of the class I Want self to refere to in front of the : . Forgive me if this is a newbie question as I am new to Lua.
Code:
local BoardQueues = {}
local playersInQueue = {}
local JoinBoardQueue = rStore:WaitForChild("JoinBoardQueueNow")
local function enqueuePlayer(player, board)
if(playersInQueue[player]) then
print("Player is already in queue")
return
end
local queue = getQueueForBoard(board)
if(queue == nil) then
--if no queue was found, make one, player will be added to queue by constructor
local newQueue = BoardQueue:new(nil, boardName, player)
table.insert(BoardQueues, newQueue)
newQueue.addPlayer(player)
else
--otherwise insert them into existing queue
queue.addPlayer(player)
end
addToQueue(player)
return board
end
JoinBoardQueue.OnServerInvoke = enqueuePlayer
--Meta class
BoardQueue = {players, boardName, leader}
--Derived class method new
--BoardQueue holds all players in queue and keeps track of whether or not it is full
function BoardQueue:new(o, boardName, leader)
o = o or {}
setmetatable(o, self)
self.__index = self
local newTable = {}
table.insert(newTable, leader)
self.players = newTable --list of queued players including leader
self.isReady = false --whether the queue is ready to start a game
self.boardName = boardName --The name of the party board
self.queueLeader = leader --The queue leader. Leader decides when to start if less than 4 players present in queue
return o
end
function BoardQueue:addPlayer(player)
print("Ready ", self.isReady)
end