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)
-- 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