Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to remove an object from a table?

hello,

I want to remove the LocalPlayer from the table so the code after I removed the player won't affect the LocalPlayer aswell.

while wait() do
	for a,b in pairs(game.Players:GetPlayers()) do
		if b.Name == game.Players.LocalPlayer.Name then
			table.remove(game.Players:GetPlayers(),1)		
		end
	end
end

The only trouble I'm having is how do I know what number position is the LocalPlayer?

1 answer

while wait() do
	for a,b in pairs(game.Players:GetPlayers()) do
		if b.Name == game.Players.LocalPlayer.Name then
			table.remove(game.Players:GetPlayers(),a) 
			--a is the index, it shows what number the loop is at.     
		end
	end
end

This discussion is preserved as it was. New answers, comments, and votes are closed.