Players not being teleported

Hey, I was trying to make my own party feature not for a game only for fun. Anyhow, I keep getting an error when I test it on a regular Roblox server that says I need to pass an array of players, but I did though with a table that I put the players in the party into. Here’s my code.

SERVERSCRIPT

local TS = game:GetService("TeleportService")

game.Players.PlayerAdded:Connect(function(player)
	local inparty = Instance.new("BoolValue", player)
	inparty.Name = "inParty"
end)

game.ReplicatedStorage.sendPlayers.OnServerEvent:Connect(function()
	local players = {}
	for i, player in game.Players:GetPlayers() do
		if player.inParty.Value == true then
			table.insert(players, player)
		end
	end
	local serverCode = TS:ReserveServer(11717066798)
	TS:TeleportToPrivateServer(11717066798, serverCode, players)
end)

wouldnt it be easier just to put the server code in the start of the script then teleport after the inparty check instead of adding it to a table then teleporting

2 Likes

Its because your “inparty” instance doesn’t have inparty.Value = true, make sure to check if the BoolValue Value is set to true

2 Likes

It’s already true. (30charlimit)

It’s a for in do value, it will keep repeating the function and I want all the players to be teleported at once.

I was kinda able to find the cause of the issue, but the issue is it doesn’t check the inParty’s value in the part where it does are for in do value.