How do I make a part require 2 people for the TouchInteract function to occur?

I have a script for when the person touches the part it teleports them to a certain position, but for the game I’m making I need the script to require 2 people, and not execute the teleportation function with only 1 person standing on the platform. Does anyone know how to do this? If I’m unclear, I’ll elaborate below.

Script:
place = CFrame.new(-48.68, 0.025, -47.13)
script.Parent.Touched:connect(function(p)
local humanoid = p.Parent:findFirstChild(“Humanoid”)
if (humanoid ~= nil) then
humanoid.Torso.CFrame = place
end
end)

I see an error right there. Is it part from the script?

Edit: You can use a NumberValue and use the ‘if’ statement.

image
It’s not apart of the script, it was just an error from the copy and pasting.
Also, I will try what you said in your edit.

Yes. Try doing a ‘Value’.Value = ‘Value’.Value = 1

I’d recommend this thread, Zone+ v1 (deprecated) | Retrieving players within an area/zone
but an example in your case would be this:

-- SERVICES & VARIABLES
local players = game:GetService("Players")
local replicatedStorage = game:GetService("ReplicatedStorage")
local Zone = require(replicatedStorage.Zone)



-- INIT ZONE
-- Setup
local Touching = 0
local TouchedPeople = {}
local newZoneGroup = workspace.SafeZone
local newZone = Zone.new(newZoneGroup)
newZone.PlayerAdded:Connect(function(player)
	Touching = Touching + 1
	table.insert(TouchedPeople,player)
	if Touching == 2 then
		--do the teleport with the table TouchedPeople
	end
end)
newZone.PlayerRemoving:Connect(function(player)
	Touching = Touching - 1
	for i,v in next, TouchedPeople do
		if v == player then
			table.remove(TouchedPeople,i)
		end
	end
end)
newZone:initLoop()

It’s a fairly basic example, just minor edited off his Examples1 script in ServerScriptService

1 Like