"Unable to cast value to Object" Teleport Service

local plrs = {}
while true do
	wait(20)
	for i, v in pairs(game:GetService("Players"):GetPlayers())do
		if v:WaitForChild("CurrentDoor").Value == "ChapterOne" then
			table.insert(plrs, i)
			game:GetService("TeleportService"):TeleportPartyAsync(5693371661, plrs)
			print("Hey")
		end
	end
end

" Unable to cast value to Object"

What am I doing wrong here? Explanation would be good as well. Also tell me if this should be in code review because I’m pretty stumped about that. Thanks :smiley:!

I know there’s a post on this already but it didn’t solve my problem.

1 Like

When posting in Scripting Support, please mention which line the error is occurring on.

It appears you’re inserting the index of the player (i) into the table, not the actual player object (v).

Change table.insert(plrs, i) to table.insert(plrs, v).

1 Like