Constantly checking

Ah right so if your using table.find theres a chance it returns nil. As you said the player is only in one of the tabels.

you could do the following

local playerFoundInTable = table.find(tableToSearchIn, playerToLookFor)

if playerFoundInTable then
    --Player Was found
else
    --Player Was not found
end

so I would do

game.Players.PlayerRemoving:Connect(function(player)
	local inidle = table.find(idle, player)
	local inplaying = table.find(playing, player)
	
	if inidle ~= nil then
		table.remove(idle, inidle)
	elseif inplaying ~= nil then
		table.remove(playing, inplaying)
	end
end)

yep it worked thanks for all your help

Yeah looks great :slightly_smiling_face: No problem, enjoy your night or day.

Why not use metatables? This is a perfect usecase for them.

You’ll need two tables because __newindex a weird metamethod, but basically here’s the code that you would need to run code. Metamethods cannot yield.

local playing = {}

local proxy = setmetatable(playing, {
  __newindex = function(self, k, v)
    print("Added " .. k)
    table.insert(playing, v) --we dont need to use the key here since it's an array, not a table

    --run table changed code here
  end})

What this setup allows you to do is check when a table updates, if you update proxy, not playing, it runs the function that __newindex is set to, we need to use a proxy table because __newindex only works when keys are added, not changed. But it does block keys from being added to the original table.