Cannot Teleport To The Main Map

Sorry For 2 Topics A Day

I just cant figure this again

my solutions were watching a video and rewriting the code

anyways here it is

-- Define Some Variables first!

local ReplicatedStorage = game:GetService('ReplicatedStorage')
local ServerStorage = game:GetService("ServerStorage")

local lengthOfRound = 250
local Intermission = 10
local ChosenPlr = nil
local ChooserPlr = nil
local Timer = 20 -- times the game
local CHOSEN = ServerStorage.Chosen
local CHOOSER = ServerStorage.Chooser
local char
local Status2 = ReplicatedStorage.Status2
local plr = game.Players:GetPlayers()
local APlayer = #plr
local Watch = workspace.Watch
local WatchView = workspace.WatchView
local Spawns = WatchView:WaitForChild("Spawns")
local Spawns1 = Watch:WaitForChild("Spawns")

local Status = ReplicatedStorage:WaitForChild("Status")

while true do
	wait(1)
	
	local plrs = {}
	
	while wait() do
		for i, v in pairs(plr) do
			table.insert(plrs, plr)
		end
		
		break
	end
	
	wait(5)
	
	Status.Value = "Waiting For Enough Players!"
	
	repeat wait() until game.Players.NumPlayers >= 1
	
	
	Status.Value = "Intermission In "..Intermission.." Seconds Left, Please Wait!"
	
	
	wait(10)
	
	
	while wait() do
		Intermission = Intermission - 1
		
		if Intermission ~= 0 then
			-- nothing
			break
		else
			print("Intermission still on")
		end
		
		break
	end	
	
	
	
	Status.Value = "Choosing The Chosen And The Chooser Players!"
	
	
	
	
		
	if #game.Players:GetChildren() > 0 then
		ChooserPlr = game.Players:GetChildren()[math.random(1,#game.Players:GetChildren())]
		
		print(ChooserPlr)
	end	
		
	
		
	
	
	
	table.remove(plrs, ChosenPlr) -- remove player the chosen one or the chooser no need for loops because its only 1 player
	
	
	print(ChosenPlr)
	
	
	
	if ChosenPlr ~= nil then
		CHOSEN.Value = ChosenPlr.Name..""
	end
	
	
		
	if #game.Players:GetChildren() > 0 then
		ChooserPlr = game.Players:GetChildren()[math.random(1,#game.Players:GetChildren())]
		
		print(ChooserPlr)
	end	
			
		
		
		
	
	
	if ChooserPlr ~= nil then
		CHOOSER.Value = ChooserPlr.Name..""
	end
	
	
	
	
	
	
	
	--		1				2			3
	--{Chosen.Name} {Chooser.Name} {Watchers}
	
	local SpawnsAvailable = Spawns:GetChildren()
	
	
	local randomspawn = SpawnsAvailable[math.random(1,#SpawnsAvailable)]
	
	local SpawnsAvailable1 = Spawns1:GetChildren()
	
	
	if not SpawnsAvailable and SpawnsAvailable1 then
		print("None Available")
	end
	
	
	
	
	wait(5)
	
	Status.Value = "Game Is Starting!"
	wait(5)
	Status.Value = "The Chosen Player Is "..CHOSEN.Value
	wait(5)
	Status.Value = "And The Chooser Is "..CHOOSER.Value
	
	wait(5)
	while Timer ~= 0 do
		if Timer ~= 0 then
			Timer = Timer - 1
		end
	end
	
	
	
	
	
	
	print(ChosenPlr)
	print(ChooserPlr)
	
	
	-- line 158 Status.Value = "Teleporting All The Players In The Game In "..Timer.."!"
	
	print(Timer)
	
	
	for i, player in pairs(plr:GetChildren(), ChooserPlr:GetChildren()) do -- line 163
		if player then
			char = player.Character
			
			if char then
			-- line 168	char:WaitForChild("HumanoidRootPart").CFrame = SpawnsAvailable.CFrame
			end
		else
			if not player then
				table.remove(plrs, i)
			end
		end
	end
	
	
	
	if ChosenPlr then -- line 179 if errors then i dont know how and why
		
		for _, player in pairs(ChosenPlr:GetChildren()) do
			char = player.Character
			
			char:WaitForChild("HumanoidRootPart").CFrame = SpawnsAvailable1.CFrame
		end
	else
		table.remove(plrs,ChosenPlr)
	end
	
end

i keep getting this error too

21:45:46.460 - ServerScriptService.Handler:163: attempt to call a nil value
21:45:46.461 - Stack Begin
21:45:46.463 - Script 'ServerScriptService.Handler', Line 163
21:45:46.464 - Stack End
4 Likes

Can you show us the line 158-168? I don’t have enouth time searching in your entire script.

look above 30char30char30char30char

You gave us 200 lines, can’t you just give us the error line? Not the number, but the line?

i gave 200 lines but the error is in line 163

So can you send the line 163? I don’t have enouth time finding it.

line 163 should look like this

for i, player in pairs(plr:GetChildren(), ChooserPlr:GetChildren()) do -- line 163

pairs() don’t have 2 arguments, only keep this:

for _, player in ipairs(plr:GetChildren()) do
1 Like

still gave me the same error tho

EDIT:
I watched this video but nothing works tho in my script not his

Apparently Fixed added some rewrites should have checked some stuff before making a topic