Hi,
I have a problem with removing and inserting tables.
The problem is that I inserted the player in a table called playersInObbyTable when I try to remove, it doesn’t seem it’s empty. I set a function detects when the table is empty, it works, but it doesn’t detect the table when the players removed from it.
local function teleportToMap(Spwans)
for i, plr in pairs(players:GetPlayers()) do
if plr.Character then
if plr.Character:FindFirstChild("HumanoidRootPart") then
plr.Character.HumanoidRootPart.CFrame = Spwans[math.random(1,#Spwans)].CFrame + Vector3.new(0,2,0)
table.insert(playersInObbyTable, plr)
end
end
end
end
endPart.Touched:Connect(function(plr)
if plr.Parent.Humanoid then
local plyr = players:GetPlayerFromCharacter(plr.Parent)
plr.Parent.HumanoidRootPart.CFrame = lobbySpwans[math.random(1,#lobbySpwans)].CFrame + Vector3.new(0,3,0)
table.insert(winnersTable, plyr)
playersInObbyTable.plyr = nil
for i,v in pairs(playersInObbyTable) do
local playerInTable = functions.GetObjectByValue(playersInObbyTable, plyr)
if v == plr.Parent and playerInTable then
playersInObbyTable.playerInTable = nil
end
end
end
end)
I tried to table.remove but that also didn’t work.
Yeah, but it doesn’t work he needs the index. I won’t know where is it in the table and I tried to check every value then remove it but also that doesn’t work.
I know how to check amount of players but that’s not problem.
Could you print the table’s content when you’ve added and removed the player from the table?
You can just loop through using for i, v in pairs(table) do print(v) end or use this really neat repr module