Can someone help me or give me some advice?

Hello fellow developers! I’ve been working on character assignments on the game I’m working on, but as all other programmers, I’m in the oh-no zone, so I need your help!

I already tried to watch some videos and got to this script, and the issue is that the “selection” table doesn’t fill up, can anyone help? I would really appreciate it! However you don’t have to :slight_smile:

Here is the script:

local detector = script.Parent
wait(2)
local teleportPart = workspace.TeleportPart
local regionPart = workspace.RegionPart
local pos1 = regionPart.Position - (regionPart.Size/2)
local pos2 = regionPart.Position + (regionPart.Size/2)
local queue = Region3.new(pos1,pos2)
local playersInQueue = 0
local teleportPart1 = workspace.TeleportPart1
local selection = {}
local Jackie = game.ReplicatedStorage.Characters.Jackie
local Nora = game.ReplicatedStorage.Characters.Nora
local Nathan = game.ReplicatedStorage.Characters.Nathan
local Kiriko = game.ReplicatedStorage.Characters.Kiriko
local Percy = game.ReplicatedStorage.Characters.Percy
local Wade = game.ReplicatedStorage.Characters.Wade
local Harper = game.ReplicatedStorage.Characters.Harper
local part
detector.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") ~= nil then
		hit.Parent:MoveTo(teleportPart.Position)
		playersInQueue = playersInQueue + 1
		table.insert(selection,1,hit.Parent.Name)
	end
end)

local function getPositionOfPlayer(tab, el)
	for i,v in pairs(selection) do
		 if v == el then
			return i
		end
	end
end


while wait() do
	local partsInRegion = workspace:FindPartsInRegion3(queue,nil,1000)
	for i, part in pairs(partsInRegion) do
		if part.Parent:FindFirstChild("Humanoid") ~= nil then
			
		end
	end
	if playersInQueue >= 7	 then
				wait(10)
		workspace.Cooldown.CanCollide = true
		wait(1)
		part.Parent:MoveTo(teleportPart1.Position)
		workspace.Cooldown.CanCollide = false
		playersInQueue = 0
	end
	
	repeat wait() until selection[1] ~= nil
	local jackie = selection{math.random(1,#selection)}
	game.ReplicatedStorage.Characters.Jackie = jackie
	table.remove(selection,getPositionOfPlayer(selection,jackie))
	
	local nora = selection{math.random(1,#selection)}
	game.ReplicatedStorage.Characters.Nora = nora
	table.remove(selection,getPositionOfPlayer(selection,nora))
	
	local nathan = selection{math.random(1,#selection)}
	game.ReplicatedStorage.Characters.Nathan = nathan
	table.remove(selection,getPositionOfPlayer(selection,nathan))
	
	local harper = selection{math.random(1,#selection)}
	game.ReplicatedStorage.Characters.Harper = harper
	table.remove(selection,getPositionOfPlayer(selection,harper))
	
	local kiriko = selection{math.random(1,#selection)}
	game.ReplicatedStorage.Characters.Kiriko = kiriko
	table.remove(selection,getPositionOfPlayer(selection,kiriko))
	
	local percy = selection{math.random(1,#selection)}
	game.ReplicatedStorage.Characters.Percy = percy
	table.remove(selection,getPositionOfPlayer(selection,percy))
	
	local wade = selection{math.random(1,#selection)}
	game.ReplicatedStorage.Characters.Wade = wade
	table.remove(selection,getPositionOfPlayer(selection,wade))
	
	for i,player in pairs(game:GetService("Players"):GetChildren()) do
		if player.Name == wade then
			Wade.Name = "StarterCharacter"
			Wade.Parent = game.StarterPack
			print(wade..": Wade")
		end
		
		if player.Name == jackie then
			Jackie.Name = "StarterCharacter"
			Jackie.Parent = game.StarterPack
			print(jackie..": Jackie")
		end
		
		if player.Name == nathan then
			Nathan.Name = "StarterCharacter"
			Nathan.Parent = game.StarterPack
			print(nathan..": Nathan")
		end
		
		if player.Name == nora then
			Nora.Name = "StarterCharacter"
			Nora.Parent = game.StarterPack
			print(nora..": Nora")	
		end
		
		if player.Name == percy then
			Percy.Name = "StarterCharacter"
			Percy.Parent = game.StarterPack
			print(percy..": Percy")	
		end
		
		if player.Name == kiriko then
			Kiriko.Name = "StarterCharacter"
			Kiriko.Parent = game.StarterPack
			print(percy..": Percy")	
		end
		
		if player.Name == harper then
			Harper.Name = "StarterCharacter"
			Harper.Parent = game.StarterPack
			print(harper..": Harper")	
		end
	end	
end