Why is my oop code changing for all tables instead of 1?

im making a table system, and when a remote event is fired, it assigns people to a table based on the value passed in the remote event. While I’m making this, my oop code is running for all of the tables instead of just one of them. How can I change this?

code:

local class = require(game.ServerStorage.Modules.Classic)

local Table = class:extend()


function Table:new(tableFolder, Tables)
	self.people = {}
	self.signLabel = tableFolder.Sign.Text.BillboardGui.TextLabel
	self.Tables = Tables
	
	--if not staff dont show
	game.Players.PlayerAdded:Connect(function(player)
		if player.Name ~= "lxgh1lxy" then
			tableFolder.Sign.Text.BillboardGui.Enabled = false
		end
	end)
	
	--ontouch claim
	game.ReplicatedStorage.Tablets.OnServerEvent:Connect(function(player, order, num, tableSit)
		for i = 1, #order do
			table.insert(self.people, order[i])
		end
	end)
	
	--onleave
	game.Players.PlayerRemoving:Connect(function(player)
		
	end)
end

function Table:update()
	if #self.people == 0 then
		self.signLabel.Text = "Vacant"
	elseif #self.people >= 1 then 
		self.signLabel.Text = "Taken"
	end
end

function Table:owns(player)
	for index, Table in pairs(self.Tables) do
		if Table.owner == player then
			return true
		end
	end
	
	return false
end

return Table

thanks

I think you should change the function definition of table:new to table.new. Replace the colon there with a period; otherwise, when if you call the function with a dot: table.new(), the first parameter you pass becomes self. If you call it with a colon: table:new(), the table variable becomes self, which is most likely the Table returned by your module. You will ofcourse have to change other things as well to work with the functionality I just described.

I don’t think there’s anything wrong with the class - if the code is running for all tables, it might suggest you’re setting up the table objects incorrectly or you’re not using the class correctly in other scripts. More context on how you’re using the class would be helpful.

@vijet1 OP is using this module which is a slightly different way of going about OOP which abstracts away metatables, but the way they’ve done it is correct.