Hello, Scripters, I'm currently making a teleport system to teleport players to an arena but I'm having an issue with table.remove. I'm using table.remove to a spawn pad that has been already used but I get an error saying attempt to index number with 'remove'. If you can help me, I will very much appreciate it. Thanks! :)
Here is the block of code!
local function SwordFight()
local CurrentPlayersInRound = Players:GetChildren()
local SpawnPadsFolder = arenaArea:WaitForChild("Teleports")
local SpawnPadsTable = SpawnPadsFolder:GetChildren()
for table, player in pairs(CurrentPlayersInRound) do
local RandomSpawnPad = math.random(1,#SpawnPadsTable)
local SpawnPad = SpawnPadsTable[RandomSpawnPad]
local SpawnPadPosition = SpawnPad.Position
local char = player.Character
local HumanoidRootPart = char:WaitForChild("HumanoidRootPart")
HumanoidRootPart.Position = SpawnPadPosition
table.remove(SpawnPadsTable, RandomSpawnPad)
end
end

2 comments
why not just do SpawnPadsTable[RandomSpawnPad]:Destroy()
you need to index the number of the object's ocation in the table