Why wont my teleporter accept more than 1 person?

Hello, I am currently making a teleport system for a client and for some odd reason the teleporter when testing it would only accept one person btw the teleporter is server-sided

-- 
placeId = 5551067564 --Replace with your the game you want to be teleported to

local TeleportSerivce = game:GetService("TeleportService")
local Players = game:GetService("Players")

local triggerPart = script.Parent
local teleportNode = script.Parent.Parent:WaitForChild("TeleportNode") -- The part that the players are teleported to
local Folder = triggerPart:WaitForChild("Players")
local timer = script.Parent.Parent.billboardpart.SurfaceGui:WaitForChild("Timer")
local playerCount =script.Parent.Parent.billboardpart.SurfaceGui:WaitForChild("PlayerCount")
local maxPlayers = 2 --This is the max ammount of players
local debouncer = false

function checkIfExist(Character)
	for _, value in pairs(Folder:GetChildren()) do
		if value.Value == Character then
			return true
		end
	end
	return false
end

function teleportParty()
	local Plrs = {}
	for _, value in pairs(Folder:GetChildren()) do
		if value.Value then
			table.insert(Plrs, Players:GetPlayerFromCharacter(value.Value))
		end
	end
	local ReserveCode = TeleportSerivce:ReserveServer(placeId)
	TeleportSerivce:TeleportToPrivateServer(placeId, ReserveCode, Plrs) --Teleports the players in the teleporters
	Folder:ClearAllChildren()
end

function countdown()
	for i = 1, 45, 1 do
		wait(1)
		timer.Text = 45 - i
	end
end

function updateGUI()
	playerCount.Text = tostring(#Folder:GetChildren()).."/"..tostring(maxPlayers)
	if #Folder:GetChildren() >= maxPlayers or timer.Text == 0 then
		teleportParty()
	end
end

triggerPart.Touched:Connect(function(hit)
	if not debouncer and  #Folder:GetChildren() < maxPlayers  then
		debouncer = true
		if hit.Parent:FindFirstChild("Humanoid") and #Folder:GetChildren() < maxPlayers then
			print("Player is touching game teleporter")
        if not checkIfExist(hit.Parent.Parent) then
			local Tag = Instance.new("ObjectValue")
			Tag.Value = hit.Parent.Parent
			Tag.Parent = Folder
			hit.Parent:SetPrimaryPartCFrame(teleportNode.CFrame)
				if #Folder:GetChildren() <= maxPlayers then
					debouncer = false
					countdown()
				end
	  end
	end
		debouncer = false
  end
end)

Folder.ChildAdded:Connect(updateGUI)
Folder.ChildRemoved:Connect(updateGUI)

local success, result = pcall(function()

	return TeleportService:TeleportPartyAsync(PLACE_ID, playerList)

end)

Hi! If hit.Parent have the child called humanoid, than hit.Parent is the character

2 Likes

Thank you this worked and now i can finish making my client’s system!

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.