How to remove variable object from table

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to remove a player’s name from a table of players who arent eliminated.
  2. What is the issue? Include screenshots / videos if possible!
    I can’t figure out how to properly do this.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have looked at and tried many methods to do this, but cant find one that works (with my implementation of it)
    I haven’t used tables or dictionaries, so i dont know much about them.
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
--!nolint explosion
--!nocheck
local Rounds = {}

function Rounds.StartRound(countdown, playercount)
	local players = game.Players:GetPlayers()
	local inplayers = players
	
	local function set(player)
		local ss = game.ServerStorage
		local la = "Left Arm"
		local plr = player
		local tnt = ss.TNT:Clone()
		tnt.Parent = game.Workspace[player.Name]
		local weld = Instance.new("WeldConstraint")
		weld.Parent = plr.Character:WaitForChild('pospart')
		local val = plr.Character.values:WaitForChild('tagged') 
		val.Value = true
		plr.Character.Humanoid.WalkSpeed = 30
		--pos calc
		local pospart = plr.Character:WaitForChild('pospart')
		local pos = pospart.Position
		--
		tnt.Position = pos
		weld.Part0 = plr.Character.pospart
		weld.Part1 = tnt

	end
	
	
	local function Explode(player)
		local players = game.Players:GetPlayers()
		local explosion = game.ServerStorage.explosion:Clone()
		explosion.Parent = game.Workspace[player.Name].Torso
		explosion.Enabled = true
		game.Workspace[player.Name].values.playing.Value = false
		local it = inplayers[math.random(#inplayers)]
		if it ~= player then
			_G.pass(player,it)
			game.Workspace[player.Name].HumanoidRootPart.CFrame = game.Workspace.SpawnTP.CFrame
			explosion:Destroy()		
end
	end
	local popupmanager = require(game.ServerStorage.ModuleScript)
	local timer = game.Workspace.Timer
	local players = game.Players:GetPlayers()
	repeat
		wait(1)
		timer.Value = countdown .. (' Seconds Until Next Round!')
		countdown = countdown - 1
	until countdown <= 0
	local it = players[math.random(1, #players)]
	set(it)
	for i,v in pairs(game.Players:GetChildren()) do
		v.Character.values.playing.Value = true
		game.Workspace[v.Name].HumanoidRootPart.CFrame = game.Workspace.indev.spawns.gametp.CFrame
	end
	local ci = game.Workspace.CurrentIT
	local itchar = game.Workspace[it.Name]
	print(itchar)
	ci.Value = itchar
	print("IT : "..(it.Name))
	local inplayers = players
	local t = 40
	repeat
		repeat
			wait(1)
			timer.Value = t .. (' Seconds Until Explosion!')
			t = t - 1
		until t <= 0
		t = 40
		local ci = game.Workspace.CurrentIT
		print(inplayers)
		Explode(ci.Value)
		print(ci.Value)
		inplayers.remove(ci.Value)
		print(#inplayers)
		print(inplayers)
	until #inplayers <= 1
		
	for i,v in pairs(game.Players:GetChildren()) do
		game.Workspace[v.Name].HumanoidRootPart.CFrame = game.Workspace.SpawnTP.CFrame
		
		local winner = inplayers[1]
		ci.Value.Character.values.tagged.Value = false
		ci.Value.Character.values.playing.Value = false
		winner.Character.values.playing.Value = false
		local tnt = ci.Value.TNT
		tnt:Destroy()
		winner.Character.values.tagged.Value = false
		popupmanager.PopUp(v, 'Winner!', winner.Name .. " Won the game!")
	end
	
end

return Rounds

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

1 Like

The specific line is 21 up from the bottom.

1 Like

table.remove ( array t, number pos )

1 Like

How would I know the number? Because the list of players is constantly changing. I don’t know much about tables or how they work

1 Like

Use table.find, the first argument is the array, the second argument is the value you want. To remove a specific player, just do:

table.remove(players, table.find(players, player))
3 Likes

Thanks! I’ll try this tomorrow morning
I’ll mark it as solution once I try it

table.remove(inplayers, table.find(inplayers, ci.Value))